Question: It's an interesting fact that this process when done on 4 digit numbers always ends up at 6174 after a few iterations. In the example above, 1112 took 5 iterations to evaluate to 6174.
Write a program that performs the above operation on all valid 4 digit numbers from 1000-9998 and find out how many iterations it takes each number to evaluate to 6174.
Also: print a frequency distribution table with number of iterations needed to reach 6174 as one column and the total count of numbers corresponding to that iteration as another. [Bonus marks if you can represent this as a nice looking graph.]
Example Output:
Iteration Total Count of Numbers 1 10 2 151 3 240