8
Given an integer N
, output the N
th positive number K
with the following property in decimal base:
For each digit I
at position P
of K
, the number formed from K
by removing the P
th digit (i.e. I
) is divisible by I
.
Example and remarks
324
is such a number:
3
divides24
2
divides34
4
divides32
Note 1: we assume that the empty number is divisible by anything, like 0
. Therefore 1
, 2
, 3
, 4
, 5
, 6
, 7
, 8
and 9
are valid.
Note 2: K
cannot contain the digit 0
, since you cannot divide by 0
.
Inputs and outputs
- You may take the input as a function argument, through
STDIN
, etc. - You may return the output from a function, through
STDOUT
, etc. - You may index those numbers starting from
0
(in which caseN >= 0
) or from1
(in which caseN > 0
), whichever suits you more.
Test cases
Those examples are indexed from 0
, so if you indexed from 1
, then add 1
to the numbers in the N
column.
N Output
0 1
4 5
8 9
15 77
16 88
23 155
42 742
47 1113
121 4244
144 6888
164 9999
Scoring
This is code-golf, so the shortest answer in bytes wins.
Here are an implementation by @LeakyNun and by @FryAmTheEggman (both in Python) if you want more test cases.
– Fatalize – 2016-06-14T06:38:44.720The first
10000
excludivisible numbers. – Leaky Nun – 2016-06-14T09:48:44.580The first
100000
(1e5
) excludivisible numbers. – Leaky Nun – 2016-06-14T09:59:20.960Related. – AdmBorkBork – 2016-06-14T12:49:42.860