Magic number of a given length Your program must take an input (n for the purpose of description) and output all permutations of a number that is n digits long with no repeating digits, where each of the digits preceding and including its index are divisible by the place in the number that it falls.

You can read about magic numbers here.

Rules:


1 &lt;= n &lt;= 10
No digits may be repeated
The leading 0 must be present (if applicable)
The 1st through xth digit of the number (starting with the first character as 1) must be divisible by x, i.e. in 30685, 3 is divisible by 1, 30 is divisible by 2, 306 is divisible by 3, 3068 is divisible by 4, and 30685 is divislbe by 5.
The program must take an integer as input (through the command line, as a function argument, etc.) and print all permutations that satisfy the rules.
Output must be separated by 1 or more white space character
Permutations may start and with zero (so they're not technically magic numbers).
The order of output does not matter
You do not need to handle unexpected input
Least characters in bytes wins


Examples

Given 1:

0
1
2
3
4
5
6
7
8
9


Given 2:

02
04
06
08
10
12
14
16
18
20
24
26
28
30
32
34
36
38
40
42
46
48
50
52
54
56
58
60
62
64
68
70
72
74
76
78
80
82
84
86
90
92
94
96
98


Given 10:

3816547290


Credit to Pizza Hut &amp; John H. Conway for the original puzzle (Option A).
Thanks to @Mego and @sp3000 for their links.
JavaScript (Firefox 30-57), 77 bytes

f=n=&gt;n?[for(s of f(n-1))for(c of"0123456789")if(s.search(c)+(s+c)%n&lt;0)s+c]:[""]


Edit: Saved 1 byte thanks to @edc65.