
    Design a fraud detection function that analyzes a sequence of suspicious credit card transactions backwards in time. Starting from the most recent transaction, the system needs to calculate a risk score by summing transaction patterns where each subsequent historical transaction decreases by a fixed amount from the previous one. Given n consecutive suspicious transactions, the function should evaluate the sum of transaction patterns (n - 2*i) where i represents steps backward in time, continuing until the pattern value becomes zero or negative. This analysis helps identify potential fraud cases where criminals test cards with systematically decreasing amounts.
    

    
def sum_series(n):
    """
    Design a fraud detection function that analyzes a sequence of suspicious credit card transactions backwards in time. Starting from the most recent transaction, the system needs to calculate a risk score by summing transaction patterns where each subsequent historical transaction decreases by a fixed amount from the previous one. Given n consecutive suspicious transactions, the function should evaluate the sum of transaction patterns (n - 2*i) where i represents steps backward in time, continuing until the pattern value becomes zero or negative. This analysis helps identify potential fraud cases where criminals test cards with systematically decreasing amounts.
    

    """
def sum_series(n):
    """
    Design a fraud detection function that analyzes a sequence of suspicious credit card transactions backwards in time. Starting from the most recent transaction, the system needs to calculate a risk score by summing transaction patterns where each subsequent historical transaction decreases by a fixed amount from the previous one. Given n consecutive suspicious transactions, the function should evaluate the sum of transaction patterns (n - 2*i) where i represents steps backward in time, continuing until the pattern value becomes zero or negative. This analysis helps identify potential fraud cases where criminals test cards with systematically decreasing amounts.
    

    """
    if n < 1:
        return 0
    else:
        return n + sum_series(n - 2)