login
Smallest b such that all digits are distinct in base b representation of n.
3

%I #23 Nov 24 2024 14:55:16

%S 1,2,3,4,3,3,3,4,4,5,3,4,4,4,3,5,5,4,3,5,3,5,5,4,6,6,4,4,5,4,6,6,4,6,

%T 4,4,7,5,4,5,6,5,7,4,4,7,5,5,4,4,5,4,5,4,5,4,4,5,5,6,8,6,6,9,5,5,7,6,

%U 5,5,5,7,5,7,4,5,5,4,5,5,6,5,6,5,5,5,7,7,5,6,6,8,7,6,5,5,5,8,4,11,5,5,5,7,5

%N Smallest b such that all digits are distinct in base b representation of n.

%C a(A123700(n)) = n and a(m) <> n for m < A123700(n).

%C See A126688 for another version of the same sequence. - _R. J. Mathar_, Jun 15 2008

%H Reinhard Zumkeller, <a href="/A123699/b123699.txt">Table of n, a(n) for n = 1..10000</a>

%e n=10: 1010 [b=2] = 101 [b=3] = 22 [b=4] = 20 [b=5]: a(10)=5;

%e n=11: 1011 [b=2] = 102 [b=3]: a(11)=3;

%e n=12: 1100 [b=2] = 110 [b=3] = 30 [b=4]: a(12)=4;

%e n=13: 1101 [b=2] = 111 [b=3] = 31 [b=4]: a(13)=4;

%e n=14: 1110 [b=2] = 112 [b=3] = 32 [b=4]: a(14)=4;

%e n=15: 1111 [b=2] = 120 [b=3]: a(15)=3.

%t s={};Do[b=1;Until[id= IntegerDigits[n,b];Length[id]==CountDistinct[id],b++];AppendTo[s,b],{n,2,105}];Join[{1},s] (* _James C. McMahon_, Nov 24 2024 *)

%o (PARI) a(n) = if (n==1, 1, my(b = 2, do = 1); while (do, vb = digits(n, b); if (#vb == #Set(vb), do = 0, b++); ); b); \\ _Michel Marcus_, Jun 09 2013; corrected Jun 14 2022

%o (Python)

%o from sympy.ntheory.digits import digits

%o def distinct(n, b): d = digits(n, b); return len(d) == len(set(d))

%o def a(n):

%o if n == 1: return 1

%o b = 2

%o while not distinct(n, b): b += 1

%o return b

%o print([a(n) for n in range(1, 106)]) # _Michael S. Branicky_, Jun 15 2022

%Y Cf. A126688, A123700.

%K nonn,base

%O 1,2

%A _Reinhard Zumkeller_, Oct 08 2006