[go: up one dir, main page]

login
a(n) is the smallest decimal number > 1 such that when it is written in all bases from base 2 to base n those numbers all contain both 0 and 1.
2

%I #29 Feb 10 2021 01:31:43

%S 2,9,19,28,145,384,1128,2601,2601,101256,103824,382010,572101,971400,

%T 1773017,1773017,22873201,64041048,64041048,1193875201,2496140640,

%U 10729882801,21660922801,120068616277,333679563001,427313653201,427313653201,10436523921264,10868368953601

%N a(n) is the smallest decimal number > 1 such that when it is written in all bases from base 2 to base n those numbers all contain both 0 and 1.

%C The sequence is infinite since 1 + lcm(2,...,n)^2 is always a candidate for a(n). - _Giovanni Resta_, May 24 2020

%H Giovanni Resta, <a href="/A335051/b335051.txt">Table of n, a(n) for n = 2..32</a>

%e a(3) = 9 as 9_2 = 1001 and 9_3 = 100, both of which contain a 0 and 1.

%e a(6) = 145 as 145_2 = 10010001, 145_3 = 12101, 145_4 = 2101, 145_5 = 1040, 145_6 = 401, all of which contain a 0 and 1.

%e a(9) = 2601 as 2601_2 = 101000101001, 2601_3 = 10120100, 2601_4 = 220221, 2601_5 = 40401, 2602_6 = 20013, 2601_7 = 10404, 2601_8 = 5051, 2601_9 = 3510, all of which contain a 0 and 1. Note that, as 2601 also contains a 0 and 1, a(10) = 2601.

%e a(16) = 1773017 as 1773017_2 = 110110000110111011001, 1773017_3 = 10100002010022, 1773017_4 = 12300313121, 1773017_5 = 423214032, 1773017_6 = 102000225, 1773017_7 = 21033101, 1773017_8 = 6606731, 1773017_9 = 3302108, 1773017_10 = 1773017, 1773017_11 = 1001104, 1773017_12 = 716075, 1773017_13 = 4A102C, 1773017_14 = 342201, 1773017_15 = 250512, 1773017_16 = 1B0DD9, all of which contain a 0 and 1.

%t a[n_] := Block[{k=2}, While[ AnyTrue[ Range[n, 2, -1], ! SubsetQ[ IntegerDigits[k, #], {0, 1}] &], k++]; k]; a /@ Range[2, 13] (* _Giovanni Resta_, May 24 2020 *)

%o (Python)

%o from numba import njit

%o @njit

%o def hasdigits01(n, b):

%o has0, has1 = False, False

%o while n >= b:

%o n, r = divmod(n, b)

%o if r == 0: has0 = True

%o if r == 1: has1 = True

%o if has0 and has1: return True

%o return has0 and (has1 or n==1)

%o @njit

%o def a(n, start=2):

%o k = start

%o while True:

%o for b in range(n, 1, -1):

%o if not hasdigits01(k, b): break

%o else: return k

%o k += 1

%o anm1 = 2

%o for n in range(2, 21):

%o an = a(n, start=anm1)

%o print(an, end=", ")

%o anm1 = an # _Michael S. Branicky_, Feb 09 2021

%Y Cf. A335066, A258107, A145100, A317725, A181929, A331565, A153114.

%K nonn,base

%O 2,1

%A _Zach J. Shannon_ and _Scott R. Shannon_, May 21 2020

%E a(29)-a(30) from _Giovanni Resta_, May 24 2020