Take a positive integer X
. This number is part of the sequence we are interested in if the sum of all digits of X
is a divisor of X
, and if the product of all digits of X
is a divisor of X
.
For example, 135
is such a number because 1 + 3 + 5 = 9
which divides 135 = 9 * 15
and 1 * 3 * 5 = 15
which also divides 135
.
This is sequence A038186 in the OEIS.
Your task: given an integer N
, output the N
th positive integer with such properties.
Inputs and outputs
Numbers may be
0
-indexed or1
-indexed; please indicate which one your answer use.The input may be taken through
STDIN
, as a function argument, or anything similar.The output may be printed to
STDOUT
, returned from a function, or anything similar.
Test cases
The test cases below are 1
-indexed.
Input Output
1 1
5 5
10 12
20 312
42 6912
50 11313
Scoring
This is code-golf, so the shortest answer in bytes wins.
0
. \$\endgroup\$