cho.sh
Notes
Loading...

Number Game

Time limit

2s

Memory limit

128 MB

Problem

Given a positive integer, add all of its decimal digits. If the result still has two or more digits, repeat the same operation. The final one-digit value is the result of the game.

For each number you are given, compute this final one-digit value.

Input

Each line contains an integer N. N is a positive integer less than 100000.

The input ends with a line containing 0. Do not output anything for this final 0.

Output

For each input number before the final 0, print its one-digit result on its own line.