Gregorio is very interested in discovering properties of non-negative integers. In one of his mathematical excursions, he tried adding all the digits of a number. Of course he ended up with a new number. He performed the same process using this new number and he got another number. If this process is one repeatedly, he realized that it always converge to a number. For example, the number 12345 converges to 6 and 99999 converges to 9.
12345 >> 15 >> 6 >> 6
99999 >> 45 >> 9 >> 9
Gregorio tasked himself in discovering the number of non-negative integers from x to y that converge to a given number z. Help Gregorio develop a program that will automate this task.
The input consists of several input lines. Each input line consists of three non-negative integers: x, y, and z. The numbers x and y are respectively the start and end points of the given range of integers. The number z is the point of convergence.
For each input line, output the number of non-negative integers from x to y that converge to z. If
x > y then output 0.
0 10 1
12345 12347 7
Or just give me some clues on how to solve this.. =)) thx..