login
Numbers that only use the digits 0 and 1 in both base 3 and 10.
1

%I #48 Sep 30 2025 03:21:37

%S 0,1,10,111,1000,1011,11110101001101,11110101001110,11110101001111,

%T 11110101010011,11110101010101,1100111000010111011100,

%U 1100111000010111011101

%N Numbers that only use the digits 0 and 1 in both base 3 and 10.

%C a(14) >= 10^312 if it exists.

%C a(14) >= 10^50000 if it exists. - _Andrew Howroyd_, Sep 26 2025

%H Michael S. Branicky, <a href="/A389119/a389119.py.txt">Python program for A389119 (translation of Andrew Howroyd's PARI) </a>

%e 1011 = 1101110_3.

%o (Python)

%o from gmpy2 import digits, mpz

%o from itertools import count, islice

%o def agen(): yield from (int(b) for k in count(0) if '2' not in digits(mpz((b:=bin(k)[2:]), 10), 3))

%o print(list(islice(agen(), 13))) # _Michael S. Branicky_, Sep 24 2025

%o (Python) # see links for translation of _Andrew Howroyd_'s PARI

%o (PARI)

%o okrange(lb,ub)={my(u=digits(lb,3),v=digits(ub,3)); if(#u < #v, 1, my(k=1); while(u[k]!= 2 && u[k]==v[k], k++); u[k]!=2)}

%o nexta(lb,ub)={

%o my(recurse(b,m)=

%o if(m==1, if(b>lb && vecmax(digits(b,3))==1 && b<ub, b, oo),

%o if(okrange(b, b+(m-1)/9), m/=10; my(r=self()(b,m)); if(r==oo, r=self()(b+m,m)); r, oo));

%o );

%o if(lb<0, 0, my(m=1,r=oo); while(r==oo &&m<ub,if(m*10>lb, r=recurse(m,m)); m*=10); r)

%o }

%o { my(k=0); while(k<oo, print1(k, ", "); k=nexta(k,10^40)) } \\ _Andrew Howroyd_, Sep 26 2025

%Y Intersection of A005836 and A007088.

%K nonn,base

%O 1,3

%A _Rhys Feltman_, Sep 23 2025