A227183
a(n) is the sum of parts of the unique unordered partition encoded in the run lengths of the binary expansion of n; row sums of A227739 for n >= 1.
Original entry on oeis.org
0, 1, 2, 2, 4, 3, 3, 3, 6, 5, 4, 6, 5, 4, 4, 4, 8, 7, 6, 8, 8, 5, 7, 9, 7, 6, 5, 7, 6, 5, 5, 5, 10, 9, 8, 10, 10, 7, 9, 11, 12, 9, 6, 10, 11, 8, 10, 12, 9, 8, 7, 9, 9, 6, 8, 10, 8, 7, 6, 8, 7, 6, 6, 6, 12, 11, 10, 12, 12, 9, 11, 13, 14, 11, 8, 12, 13, 10, 12, 14
Offset: 0
19 has binary expansion "10011", thus the maximal runs of identical bits (scanned from right to left) are [2,2,1]. We subtract one from each after the first one, to get [2,1,0] and then form their partial sums as [2,2+1,2+1+0], which thus maps to unordered partition {2+3+3} which adds to 8. Thus a(19)=8.
-
Table[Function[b, Total@ Accumulate@ Prepend[If[Length@ b > 1, Rest[b] - 1, {}], First@ b] - Boole[n == 0]]@ Map[Length, Split@ Reverse@ IntegerDigits[n, 2]], {n, 0, 79}] // Flatten (* Michael De Vlieger, May 09 2017 *)
-
def A227183(n):
'''Sum of parts of the unique unordered partition encoded in the run lengths of the binary expansion of n.'''
s = 0
b = n%2
i = 1
while (n != 0):
n >>= 1
if ((n%2) == b): # Staying in the same run of bits?
i += 1
else: # The run changes.
b = n%2
s += i
return(s)
A227738
Irregular table read by rows: each row n (n>=1) lists the positions where the runs of bits change between 0's and 1's in the binary expansion of n, when scanning it from the least significant to the most significant end.
Original entry on oeis.org
1, 1, 2, 2, 2, 3, 1, 2, 3, 1, 3, 3, 3, 4, 1, 3, 4, 1, 2, 3, 4, 2, 3, 4, 2, 4, 1, 2, 4, 1, 4, 4, 4, 5, 1, 4, 5, 1, 2, 4, 5, 2, 4, 5, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 3, 4, 5, 3, 4, 5, 3, 5, 1, 3, 5, 1, 2, 3, 5, 2, 3, 5, 2, 5, 1, 2, 5, 1, 5, 5, 5, 6, 1, 5, 6, 1, 2, 5, 6
Offset: 1
Table begins as:
Row n in Terms on
n binary that row
1 1 1;
2 10 1,2;
3 11 2;
4 100 2,3;
5 101 1,2,3;
6 110 1,3;
7 111 3;
8 1000 3,4;
9 1001 1,3,4;
10 1010 1,2,3,4;
11 1011 2,3,4;
12 1100 2,4;
13 1101 1,2,4;
14 1110 1,4;
15 1111 4;
16 10000 4,5;
etc.
The terms also give the partial sums of runlengths, when the binary expansion of n is scanned from the least significant to the most significant end.
Each row n (n>=1) contains the initial
A005811(n) nonzero terms from the beginning of row n of
A227188.
A227192(n) gives the sum of terms on row n.
A136480 gives the first column.
-
T:= n-> (l-> seq(`if`(l[i]=1, i, [][]), i=1..nops(l)))(
Bits[Split](Bits[Xor](n, iquo(n, 2)))):
seq(T(n), n=1..50); # Alois P. Heinz, Feb 01 2023
-
Table[Rest@FoldList[Plus,0,Length/@Split[Reverse[IntegerDigits[n,2]]]],{n,34}]//Flatten (* Wouter Meeussen, Aug 31 2013 *)
A227188
Square array A(n,k) read by antidiagonals: the one-based bit-index where the (k+1)-st run in the binary expansion of n ends, as read from the least significant end.
Original entry on oeis.org
0, 0, 1, 0, 0, 1, 0, 0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3, 2
Offset: 0
The top-left corner of the array:
row # row starts as
0 0, 0, 0, 0, 0, ...
1 1, 0, 0, 0, 0, ...
2 1, 2, 0, 0, 0, ...
3 2, 0, 0, 0, 0, ...
4 2, 3, 0, 0, 0, ...
5 1, 2, 3, 0, 0, ...
6 1, 3, 0, 0, 0, ...
7 3, 0, 0, 0, 0, ...
8 3, 4, 0, 0, 0, ...
9 1, 3, 4, 0, 0, ...
10 1, 2, 3, 4, 0, ...
11 2, 3, 4, 0, 0, ...
12 2, 4, 0, 0, 0, ...
13 1, 2, 4, 0, 0, ...
14 1, 4, 0, 0, 0, ...
15 4, 0, 0, 0, 0, ...
16 4, 5, 0, 0, 0, ...
etc.
For example, for n = 8, whose binary expansion is "1000", we get the run lengths 3 and 1 (scanning from the right), partial sums of which are 3 and 4, thus row 8 begins as A(8,0)=3, A(8,1)=4, A(8,2)=0, ...
-
A227188 := proc(n,k)
local bdgs,ru,i,b,a;
bdgs := convert(n,base,2) ;
if nops(bdgs) = 0 then
return 0 ;
end if;
ru := 0 ;
i := 1 ;
b := op(i,bdgs) ;
for i from 2 to nops(bdgs) do
if op(i,bdgs) <> op(i-1,bdgs) then
if ru = k then
return i-1;
end if;
ru := ru+1 ;
end if;
end do:
if ru =k then
nops(bdgs) ;
else
0 ;
end if;
end proc: # R. J. Mathar, Jul 23 2013
-
Table[PadRight[Rest@FoldList[Plus,0,Length/@Split[Reverse[IntegerDigits[j,2]]]],i+1-j][[i+1-j]],{i,0,12},{j,0,i}] (* Wouter Meeussen, Aug 31 2013 *)
-
(define (A227188 n) (A227188bi (A002262 n) (A025581 n)))
(define (A227188bi n k) (cond ((< (A005811 n) (+ 1 k)) 0) ((zero? k) (A136480 n)) (else (+ (A136480 n) (A227188bi (A163575 n) (- k 1))))))
A360259
a(0) = 0, and for any n > 0, let k > 0 be as small as possible and such that F(2) + ... + F(1+k) >= n (where F(m) denotes A000045(m), the m-th Fibonacci number); a(n) = k + a(F(2) + ... + F(1+k) - n).
Original entry on oeis.org
0, 1, 3, 2, 6, 4, 3, 10, 6, 7, 5, 4, 15, 8, 9, 11, 7, 8, 6, 5, 21, 10, 11, 13, 12, 16, 9, 10, 12, 8, 9, 7, 6, 28, 12, 13, 15, 14, 18, 16, 15, 22, 11, 12, 14, 13, 17, 10, 11, 13, 9, 10, 8, 7, 36, 14, 15, 17, 16, 20, 18, 17, 24, 20, 21, 19, 18, 29, 13, 14, 16
Offset: 0
The first terms, alongside the corresponding k's, are:
n a(n) k
----- ---- ---
0 0 N/A
1 1 1
2 3 2
3 2 2
4 6 3
5 4 3
6 3 3
7 10 4
8 6 4
9 7 4
10 5 4
11 4 4
12 15 5
-
{ t = k = 0; print1 (0); for (n = 1, #a = vector(70), if (n > t, t += fibonacci(1+k++);); print1 (", "a[n] = k+if (t==n, 0, a[t-n]));); }
Showing 1-4 of 4 results.
Comments