this is to find the sum of digits of a number until it is a single digit this method reduces time complexity by a factor of n and also without using any loop this is to find the sum of digits of a number until it is a single digit here n is the number this method reduces time complexity by a factor of n and also without using any loop
def sum_of_digits(n):
    n = int(input()) 
    if n % 9 != 0:
        print(n % 9)
    else:
        print("9")