19
1
Challenge
Given an integer, n
, as input where 36 >= n >= 2
, output how many Lynch-Bell numbers there are in base n
.
The output must be in base 10.
Lynch-Bell Numbers
A number is a Lynch-Bell numbers if:
- All of its digits are unique (no repetition of digits)
- The number is divisible by each of its digits
- It doesn't contain zero as one of its digits
Since, all of the digits have to be unique, and you have a finite set of single digit numbers in each base, there is a finite number of Lynch-Bell numbers.
For example, in base 2 there is only one Lynch-Bell number, 1
, since all other numbers either repeat digits or contain a 0.
Examples
Input > Output
2 > 1
3 > 2
4 > 6
5 > 10
6 > 10
7 > 75
8 > 144
9 > 487
10 > 548
Mathematica Online ran out of memory above base 10. You can use the following code to generate your own:
Do[Print[i," > ",Count[Join@@Permutations/@Rest@Subsets@Range[#-1],x_/;And@@(x\[Divides]FromDigits[x,#])]&[i]],{i,10,36,1}]
Winning
Shortest code in bytes wins.
1@MagicOctopusUrn Why do we need a dictionary? We don't need to output in that base. – user202729 – 2017-09-11T16:01:54.677
@BetaDecay That will turns the problem into a kolmogorov-complexity one. – user202729 – 2017-09-11T16:02:25.797
@user202729 Yep, I've edited it now – Beta Decay – 2017-09-11T16:03:18.010
@MagicOctopusUrn Sorry I didn't read the problem specification carefully. Output ... in base
n
. – user202729 – 2017-09-11T16:05:19.3172could you add an example
>10
? – Rod – 2017-09-11T16:05:51.697The output does not actually need to be in base
n
, right? ("...output how many Lynch-Bell numbers there are in basen
" appears to have caused some confusion.) – Jonathan Allan – 2017-09-11T16:07:54.8271@JonathanAllan I see, I've cleared that up now – Beta Decay – 2017-09-11T16:08:38.583
3If only [2-36] need be supported we may as well list them all. – Jonathan Allan – 2017-09-11T16:09:12.160
Related, also related – James – 2017-09-11T16:11:22.287
That I've said,
No, up to 36 should be fine
will turns the problem into a kolmogorov-complexity one. – user202729 – 2017-09-11T16:11:23.823http://oeis.org/A034838 may be helpful. – Magic Octopus Urn – 2017-09-11T16:41:20.180
3Turns out that no one has managed to calculate
f(36)
. Make a fastest-code challenge based on this would be probably interesting. – user202729 – 2017-09-25T10:15:38.947