#K94702. Lucky Numbers Finder
Lucky Numbers Finder
Lucky Numbers Finder
You are given an integer \(n\) (with \(0 \le n \le 1000\)). A lucky number is defined as a number which eventually reaches 1 when replaced by the sum of the squares of its digits repeatedly. In mathematical terms, for a number \(x\), define the function \(f(x) = \sum_{d \in digits}(d^2)\). A number \(x\) is lucky if there exists a sequence \(x, f(x), f(f(x)), \dots \) which eventually equals 1.
Your task is to print all lucky numbers less than or equal to \(n\) in ascending order separated by a single space.
inputFormat
The input consists of a single integer \(n\) provided via standard input. \(n\) satisfies \(0 \le n \le 1000\).
outputFormat
Output all lucky numbers that are \(\le n\), separated by a single space, in a single line via standard output. If there are no lucky numbers, output an empty line.
## sample10
1 7 10