login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A038102 Numbers k such that k is a substring of its base-2 representation. 13

%I #53 Jan 08 2022 22:12:24

%S 0,1,10,11,100,101,110,111,1000,1001,1100,1101,10000,10001,10011,

%T 10100,10101,10111,11000,11001,11100,11101,100000,100001,101000,

%U 101010,101100,101101,101111,110000,110001,110101,111100,111101,1000000

%N Numbers k such that k is a substring of its base-2 representation.

%H Hans Havermann, <a href="/A038102/b038102.txt">Table of n, a(n) for n = 1..1512</a> (terms 1..1000 from Giovanni Resta, terms 1001..1167 from Robert G. Wilson v).

%H Hans Havermann, <a href="/A038102/a038102.pdf">pdf file showing the corresponding A350572 terms and illustrating the binary embeddings</a> (for terms 1..1512).

%e 101000_10 = 1100010{101000}1000_2.

%t Select[FromDigits /@ IntegerDigits[Range[2^15]-1, 2], StringPosition[StringJoin @@ (ToString /@ IntegerDigits[#, 2]), ToString@#] != {} &] (* terms < 10^15, _Giovanni Resta_, Apr 30 2013 *)

%t f[n_] := Block[{a = FromDigits@ IntegerDigits[n, 2]}, If[ StringPosition[ ToString@ FromDigits@ IntegerDigits[ a, 2], ToString@ a] != {}, a, 0]]; k = 0; lst = {}; While[k < 65, AppendTo[lst, f@k]; lst = Union@ lst; k++]; lst (* _Robert G. Wilson v_, Jun 29 2014 *)

%o (PARI) {for(vv=0, 200, bvv=binary(vv);

%o mm=length(bvv); texp=0; btod=0;

%o forstep(i=mm, 1, -1, btod=btod+bvv[i]*10^texp; texp++);

%o bigb=binary(btod); lbb=length(bigb); swsq=1;

%o for(k=0, lbb - mm , for(j=1, mm, if(bvv[j]!=bigb[j+k], swsq=0));

%o if(swsq==1, print1(btod, ", "); break, swsq=1)))}

%o \\\ _Douglas Latimer_, Apr 29 2013

%o (Python)

%o from itertools import count, islice, product

%o def ok(n): return int(max(str(n))) < 2 and str(n) in bin(n)

%o def agen(): # generator of terms

%o yield 0

%o for d in count(1):

%o for rest in product("01", repeat=d-1):

%o k = int("1" + "".join(rest))

%o if ok(k):

%o yield k

%o print(list(islice(agen(), 35))) # _Michael S. Branicky_, Jan 04 2022

%Y Cf. A038103, A038104, A038105, A038106, A228050, A228051, A228052, A227549, A350572.

%K nonn,base,easy

%O 1,3

%A _Patrick De Geest_, Feb 15 1999

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 10:01 EDT 2024. Contains 371967 sequences. (Running on oeis4.)