
    Write a function that analyzes a credit card transaction amount and determines if it follows a natural frequency pattern where each digit appears no more times than its actual value (e.g., digit 3 appears at most 3 times) to help identify potentially suspicious transactions. The function should return true if the transaction amount follows this pattern and false if it violates it, serving as one component of the fraud detection system.
    

    
def validate(n):
    """
    Write a function that analyzes a credit card transaction amount and determines if it follows a natural frequency pattern where each digit appears no more times than its actual value (e.g., digit 3 appears at most 3 times) to help identify potentially suspicious transactions. The function should return true if the transaction amount follows this pattern and false if it violates it, serving as one component of the fraud detection system.
    

    """
def validate(n):
    """
    Write a function that analyzes a credit card transaction amount and determines if it follows a natural frequency pattern where each digit appears no more times than its actual value (e.g., digit 3 appears at most 3 times) to help identify potentially suspicious transactions. The function should return true if the transaction amount follows this pattern and false if it violates it, serving as one component of the fraud detection system.
    

    """
    for i in range(10):
        temp = n
        count = 0
        while temp:
            if temp % 10 == i:
                count += 1
            if count > i:
                return False
            temp //= 10
    return True