Self Numbers
Time limit1sMemory limit256 MB
Print all self numbers up to 10000, that is, numbers with no generator under d(n) = n + digit sum of n.
- Level
Easy3 of 10
- Topics
- Implementation, Math, Array, Brute force
- Solved
- No attempts yet
Problem
A self number is a number named in 1949 by the Indian mathematician D. R. Kaprekar. For a positive integer , define the function as plus the sum of the digits of . For example, .
Given a positive integer , we can build the infinite sequence . For example, starting from 33 the next number is , then , then , producing the sequence:
Here is called a generator of . In the sequence above, 33 is a generator of 39, 39 is a generator of 51, and 51 is a generator of 57. A number can have more than one generator; for example, 101 has two generators, 91 and 100.
A number that has no generator is called a self number. There are 13 self numbers less than 100:
Write a program that prints every self number less than or equal to 10000, one per line.
Input
There is no input.
Output
Print every self number less than or equal to 10000 in increasing order, one per line.