A117127 Concatenate the first n positive integers written in binary (with each integer written so the most significant 1 is on the left and the concatenated string is from left to right). a(n) is the number of times n written in binary appears in the concatenated string.
1, 1, 2, 1, 2, 3, 3, 1, 2, 1, 4, 3, 4, 5, 4, 1, 2, 2, 3, 2, 3, 2, 7, 3, 4, 4, 6, 6, 5, 7, 5, 1, 2, 2, 3, 1, 4, 3, 4, 2, 4, 2, 5, 2, 4, 4, 9, 3, 4, 5, 5, 4, 6, 4, 9, 6, 6, 6, 7, 9, 6, 9, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 5, 2, 6, 4, 5, 2, 4, 3, 6, 3, 5, 4, 7, 2, 5, 4, 7, 3, 7, 5, 11, 3, 4, 5, 5, 4, 7, 5, 7, 4
Offset: 1
Examples
The first 13 positive integers written in binary and concatenated is 11011100101110111100010011010101111001101. 13 in binary, which is 1101, appears 4 times in the concatenated string, starting at positions (reading from left to right) 1, 12, 25 and 38. The last occurrence of 1101 is the integer 13 itself converted to binary and added to the end of the concatenated string, of course. So a(13) = 4.
Links
- Diana Mecum and Robert G. Wilson v, Table of n, a(n) for n = 1..10000
Programs
-
Maple
A007088 := proc(n) convert(n,base,2) ; ListTools[Reverse](%) ; end: A058935 := proc(n) local i,a ; if n = 0 then RETURN([0]) ; else a := [] ; for i from 1 to n do a := [op(a),op(A007088(i))] ; od: fi ; end: A117127 := proc(n) local a058935,strtL,endL,nL,a ; nL := A007088(n) ; a058935 := A058935(n) ; a := 0 ; for strtL from 1 to nops(a058935) do for endL from strtL to nops(a058935) do if verify[sublist]( nL, [op(strtL..endL, a058935)] ) then a := a+1 ; fi ; od: od ; RETURN(a) ; end: for n from 1 to 80 do printf("%d, ",A117127(n)) ; od: # R. J. Mathar, Jan 23 2008
-
Mathematica
a[n_] := StringCount[ ToString@ FromDigits@ Flatten@ IntegerDigits[ Range@n, 2], ToString@ FromDigits@ IntegerDigits[n, 2], Overlaps -> True]; Array[a, 105] (* Robert G. Wilson v, Aug 30 2008 *) fc[n_]:=Module[{idn2=IntegerDigits[n,2],len},len=Length[idn2];Count[ Partition[ Flatten[Table[IntegerDigits[i,2],{i,n}]],len,1],idn2]]; Array[fc,110] (* Harvey P. Dale, Dec 16 2011 *)
Extensions
More terms from R. J. Mathar, Jan 23 2008
Terms 81 through 2000 from Diana L. Mecum, Aug 06 2008
Comments