A positive number n > 0 is “strange” if when adding each of its digits raised to the number of digits that make it up, we obtain the number itself.
For example, 153 (which has three digits) is “strange”, 153 = 13 + 53 + 33.
Make a program that returns the first n “strange” numbers.
Input A positive integer, n > 0, asking for the first n “strange” numbers.
Output Prints the list with the first n “strange” numbers.
Observation
It is forbidden to use any external function except cin
and
cout
, and also the program must be well documented if not it will be
invalidated.
Input
15
Output
1 2 3 4 5 6 7 8 9 153 370 371 407 1634 8208