Question
Self Dividing Number
A number n is called a self-dividing number if it is divisible by each of its digits and contains no zero digits. Given a number n, print all self-dividing numbers from 1 to n.
Note : Numbers containing the digit 0 are not considered self-dividing.
Input
A single integer n.
Output
Print all self-dividing numbers from 1 to n, separated by space. If none exist, print -1.

Example
Input:
22
Output:
1 2 3 4 5 6 7 8 9 11 12 15 22

Explanation:
A self-dividing number is a number that is divisible by each of its digits, and any zero digit disqualifies the number.
12 is self-dividing because it is divisible by both its digits: 12 % 1 = 0 and 12 % 2 = 0.
15 is self-dividing because it is divisible by both its digits: 15 % 1 = 0 and 15 % 5 = 0.
10 is not self-dividing because it contains the digit 0 (division by zero is not allowed).
14 is not self-dividing because 14 % 4 ≠ 0.
Thus, all self-dividing numbers from 1 to 22 are: 1 2 3 4 5 6 7 8 9 11 12 15 22.

Online