OFFSET
1,2
LINKS
Bert Dobbelaere, Table of n, a(n) for n = 1..150
EXAMPLE
10011 expressed in binary is 10011100011011_2. It is the smallest number for which the first 5 digits coincide, so a(5)=10011.
PROG
(Python)
RDXHI=10
RDXLO=2
def solvematch(startHi, startLo, digleft, powHi, powLo):
....global RDXHI, RDXLO
....if digleft<=0:
........return startHi
....if powHi<0 or powLo<0:
........return None
....startd = 1 if startHi==0 else 0
....for d in range(startd, RDXLO):
........bh=startHi + d * RDXHI**powHi
........bl=startLo + d * RDXLO**powLo
........if bh<(bl+RDXLO**powLo) and bl<(bh+RDXHI**powHi):
............res=solvematch(bh, bl, digleft-1, powHi-1, powLo-1)
............if res!=None:
................return res
....return None
def A305213(n):
....if n<=1:
........return 0 # Special case: leading and only digit is 0
....d_hi =n-1
....sol=None
....while sol==None:
........d_lo=d_hi
........while(RDXLO**d_lo < 2* RDXHI**d_hi):
............res=solvematch(0, 0, n, d_hi, d_lo)
............if res!=None:
................sol = min(sol, res) if sol else res
............d_lo+=1
........d_hi+=1
....return sol
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Bert Dobbelaere, May 27 2018
STATUS
approved