# Arup Guha
# 10/1/2020
# Consider the process of finding the sum of the digits of a number and
# repeating the process until you get down to a single digit. We'll call
# this number the digital root of the original number. This program
# calculates the digital root of the input.

# Get input.
n = int(input("Enter a positive integer.\n"))

rootNumber = 1

# Outer loop, keep on calculating sum of digits until we get down to 1 digit.
while n >= 10:

    # Accumulator for sum.
    sumDigits = 0

    # Keep on going until we peel off each digit.
    while n > 0:

        # Add in the last digit.
        sumDigits = sumDigits + n%10

        # Now we can peel off that digit.
        n = n//10

    # Reassign n to be the sum of the digits of the old n.
    n = sumDigits

    # For each iteration print the new sum of digits.
    print("Root number",rootNumber,"is",n)
    rootNumber = rootNumber + 1

# Print the final digital root.
print("The final digital root is", n)

