A076141 Number of times n occurs as a binary sub-pattern of n^2.
1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
Offset: 0
Examples
a(27) = 1 as 27 = '11011' occurs in 27^2=729 = '1011011001' once: '**11011***'.
Links
- Robert Israel, Table of n, a(n) for n = 0..10000
Crossrefs
Cf. A018826.
Programs
-
Maple
f:= proc(n) local S,S2; S:= convert(convert(n,binary),string); S2:= convert(convert(n^2,binary),string); nops([StringTools:-SearchAll(S,S2)]) end proc: map(f, [$0..200]); # Robert Israel, Jul 11 2018
-
PARI
issub(b, bs, k) = {for (i=1, #b, if (b[i] != bs[i+k-1], return (0));); return (1);} a(n) = {if (n, b = binary(n), b = [0]); if (n, bs = binary(n^2), bs = [0]); sum(k=1, #bs - #b +1, issub(b, bs, k));} \\ Michel Marcus, Mar 15 2015
Comments