チャレンジ
Given an integer, n
, as input where 36 >=
, output how many リンチベル番号 there are in base
n >= 2
n
.
出力は10進数でなければなりません。
リンチベル番号
A number is a リンチベル番号 if:
- すべての数字は一意です(数字の繰り返しはありません)。
- 数字は各桁で割り切れる
- 数字の1つとしてゼロを含まない
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 リンチベル番号.
たとえば、基数2では、他のすべての数字は数字を繰り返すか0を含むため、1つのリンチベル番号 1
のみが存在します。
例
Input > Output
2 > 1
3 > 2
4 > 6
5 > 10
6 > 10
7 > 75
8 > 144
9 > 487
10 > 548
Mathematica
Onlineのメモリが10を超えていた。次のコードを使って自分自身を生成することができる:
Do[Print[i," > ",Count[[email protected]@Permutations/@[email protected]@Range[#-1],x_/;[email protected]@(x[Divides]FromDigits[x,#])]&[i]],{i,10,36,1}]
勝つ
バイト単位の最短コードが勝ちます。
ベストアンサー
Jelly, 13 bytes
Q⁼g
*`Ṗ©bç"®S
別の O(n n )ソリューション。
説明
Q⁼g Helper link. Input: digits (LHS), integer (RHS)
Q Unique (digits)
⁼ Match
g GCD between each digit and the integer
*`Ṗ©bç"®S Main link. Input: integer n
*` Compute n^n
Ṗ Pop, forms the range [1, n^n-1]
© Store previous result in register
b Convert each integer to base n
ç" Call the helper link, vectorized, with
® The register's value
S Sum