%I #21 Dec 16 2024 14:37:29
%S 0,10,110,10010,10011,110101,10011000,10011000,110100011,10010101000,
%T 10010101001,101111000101,10010001101010,10010001101010,
%U 101101111110011,1111110010100011,10001110000111111,101100111001011100,1111011010110001101,10001010110010101011,101011110011100111110
%N a(n) is the smallest nonnegative integer whose first n binary digits coincide with its first n decimal digits.
%H Bert Dobbelaere, <a href="/A305213/b305213.txt">Table of n, a(n) for n = 1..150</a>
%e 10011 expressed in binary is 10011100011011_2. It is the smallest number for which the first 5 digits coincide, so a(5)=10011.
%o (Python)
%o RDXHI=10
%o RDXLO=2
%o def solvematch(startHi, startLo, digleft, powHi, powLo):
%o global RDXHI, RDXLO
%o if digleft<=0:
%o return startHi
%o if powHi<0 or powLo<0:
%o return None
%o startd = 1 if startHi==0 else 0
%o for d in range(startd, RDXLO):
%o bh=startHi + d * RDXHI**powHi
%o bl=startLo + d * RDXLO**powLo
%o if bh<(bl+RDXLO**powLo) and bl<(bh+RDXHI**powHi):
%o res=solvematch(bh, bl, digleft-1, powHi-1, powLo-1)
%o if res!=None:
%o return res
%o return None
%o def A305213(n):
%o if n<=1:
%o return 0 # Special case: leading and only digit is 0
%o d_hi =n-1
%o sol=None
%o while sol==None:
%o d_lo=d_hi
%o while(RDXLO**d_lo < 2* RDXHI**d_hi):
%o res=solvematch(0, 0, n, d_hi, d_lo)
%o if res!=None:
%o sol = min(sol, res) if sol else res
%o d_lo+=1
%o d_hi+=1
%o return sol
%Y Not a subsequence of A181929 (consider 10010).
%K nonn,base
%O 1,2
%A _Bert Dobbelaere_, May 27 2018