OFFSET
1,3
COMMENTS
The main idea behind my program is that if we say start searching from 10000, which is 10011... binary, then as the binary string for the first 5 places is larger than our decimal value, then the decimal value can be immediately jumped to 10011 for the next search number. Repeating this process (while also doing slight jumps if the decimal value is larger than the binary), allows ones to do very large jumps in the checked decimal values, sometimes eliminating an entire string of length n in just a few checks. I got the idea from similar people were using when searching for the next term in A258107. - Scott R. Shannon, Feb 25 2021
LINKS
Scott R. Shannon, Table of n, a(n) for n = 1..1000
EXAMPLE
The number 110 is represented in the binary system by the string "1101110". 110 is a three-digit number, so we consider the 3 most significant bits, which are "110", identical to the string of digits used to represent the number 110. Thus 110 is in the sequence.
MATHEMATICA
fQ[n_] := Module[{d = IntegerDigits[n], len}, len = Length[d]; d == Take[IntegerDigits[n, 2], len]]; Select[Range[0, 1000000], fQ] (* T. D. Noe, Apr 03 2012 *)
PROG
(PARI) {for(vv=0, 2000000, bvv=binary(vv);
ll=length(bvv); texp=0; btod=0;
forstep(i=ll, 1, -1, btod=btod+bvv[i]*10^texp; texp++);
bigb=binary(btod); swsq=1;
for(j=1, ll, if(bvv[j]!=bigb[j], swsq=0));
if(swsq==1, print(btod)))}
(PARI) lista(nn) = {for (n=0, nn, if (n==0, print1(n, ", "), my(b = binary(n), db = fromdigits(b), bb = binary(db)); if (vector(#b, k, bb[k]) == b, print1(db, ", ")); ); ); } \\ Michel Marcus, Feb 10 2021
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Douglas Latimer, Apr 02 2012
STATUS
approved