OFFSET
1,1
COMMENTS
LINKS
PROG
(ARIBAS): function b2revadd_steps(k, stop: integer); var c, n, m, steps, rev: integer; begin n := 0; c := 0; while c < stop do m := n; rev := b2reverse(m); steps := 0; while steps < k and m <> rev do m := m + rev; rev := b2reverse(m); inc(steps); end; if steps = k and m = rev then write(n, " "); inc(c); end; inc(n); end; end; b2revadd_steps(1, 66).
(PARI) Rev(x)= { local(d, r=0); while (x>0, d=x%10; x\=10; r=r*10 + d); return(r) } digitsIn(x)= { local(d); if (x==0, return(1)); d=1 + log(x)\log(10); if (10^d == x, d++, if (10^(d-1) > x, d--)); return(d) } Palin(x)= { local(d, e, f, i, t, y); if (x==0, return(1)); y=x; d=digitsIn(x); t=10^(d - 1); for (i=1, d\2, f=y-10*(y\10); y\=10; e=x\t; x-=t*e; t/=10; if (e!=f, return(0)) ); return(1) } baseE(x, b)= { local(d, e=0, f=1); while (x>0, d=x-b*(x\b); x\=b; e+=d*f; f*=10); return(e) } baseI(x, b)= { local(d, e=0, f=1); while (x>0, d=x-10*(x\10); x\=10; e+=d*f; f*=b); return(e) } { n=0; for (m=1, 10^9, b=baseE(m, 2); r=Rev(b); d=baseI(r, 2) + m; b=baseE(d, 2); if (Palin(b), write("b066122.txt", n++, " ", m); if (n==1000, return)) ) } \\ Harry J. Smith, Feb 01 2010
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Klaus Brockhaus, Dec 08 2001
EXTENSIONS
OFFSET changed from 0,1 to 1,1 by Harry J. Smith, Feb 01 2010
STATUS
approved