
    Design a fraud detection algorithm that calculates the number of possible ways a sequence of n customer transactions can be arranged such that exactly m transactions show higher amounts than their following transactions, helping identify suspicious spending patterns. The algorithm must analyze the relative ordering of consecutive transactions to establish baseline patterns for each customer's spending behavior.
    

    
def eulerian_num(n, m):
    """
    Design a fraud detection algorithm that calculates the number of possible ways a sequence of n customer transactions can be arranged such that exactly m transactions show higher amounts than their following transactions, helping identify suspicious spending patterns. The algorithm must analyze the relative ordering of consecutive transactions to establish baseline patterns for each customer's spending behavior.
    

    """
def eulerian_num(n, m):
    """
    Design a fraud detection algorithm that calculates the number of possible ways a sequence of n customer transactions can be arranged such that exactly m transactions show higher amounts than their following transactions, helping identify suspicious spending patterns. The algorithm must analyze the relative ordering of consecutive transactions to establish baseline patterns for each customer's spending behavior.
    

    """
    if m >= n or n == 0:
        return 0
    if m == 0:
        return 1
    return (n - m) * eulerian_num(n - 1, m - 1) + (m + 1) * eulerian_num(n - 1, m)