Continuous Digits Sum

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 62M

Author:
Problem type

Did you win the Digits Game? It's time for round 2. This time, you must take a single integer and add up all of its individual digits, but you must keep doing this until the sum is a single digit number between 1-9.

Input Specification

The first and only line of input will contain a single integer not greater than 25 digits in length.

Output Specification

Sum the individual digits of the integer and continue to do so to the sum until you are left with a number between 1 and 9.

Sample Input

25938

Sample Output

9

Explanation for Sample Input

The first sum is 2 + 5 + 9 + 3 + 8 = 27. From there we calculate 2 + 7 = 9. Because 9 is a single digit number, that is our final result.


Comments


  • 0
    Samuel_Liu  commented on Nov. 6, 2019, 2:10 p.m.

    The link uses tssoj.me instead of tssoj.ca >:(


    • 0
      jsumabat  commented on Nov. 6, 2019, 6:08 p.m.

      When we migrated links to tssoj.ca, this does not mean the links in problem statements were changed as well. The problem authors are responsible for maintaining their own problems.