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 *)
A227185
The largest part in the unordered partition encoded in the runlengths of the binary expansion of n.
Original entry on oeis.org
0, 1, 1, 2, 2, 1, 2, 3, 3, 2, 1, 2, 3, 2, 3, 4, 4, 3, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 4, 3, 4, 5, 5, 4, 3, 4, 3, 2, 3, 4, 3, 2, 1, 2, 3, 2, 3, 4, 5, 4, 3, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, 4, 5, 6, 6, 5, 4, 5, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 4, 5, 4, 3, 2, 3, 2, 1, 2
Offset: 0
12 has binary expansion "1100", for which the lengths of runs (consecutive blocks of 0- or 1-bits) are [2,2]. Converting this to a partition in the manner explained in A227184 gives the partition {2+3}. Its largest part is 3, thus a(12)=3, which is actually the first time when this sequence differs from A043276.
a(n) gives the rightmost nonzero term on the n-th row of
A227189.
-
Table[Function[b, Max@ Accumulate@ Prepend[If[Length@ b > 1, Rest[b] - 1, {}], First@ b] - Boole[n == 0]]@ Map[Length, Split@ Reverse@ IntegerDigits[ n, 2]], {n, 0, 120}] // Flatten (* Michael De Vlieger, May 09 2017 *)
-
(define (A227185 n) (if (zero? n) n (+ 1 (- (A029837 (+ 1 n)) (A005811 n)))))
(define (A227185v2 n) (if (zero? n) n (car (reverse (binexp_to_ascpart n))))) ;; Alternative definition, using the auxiliary functions given in A227184.
A227186
Array A(n,k) read by antidiagonals: the length of the (k+1)-th run (k>=0) of binary digits of n, first run starting from the least significant bit of n.
Original entry on oeis.org
0, 0, 1, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 0
Offset: 0
The top-left corner of the array:
0, 0, 0, 0, 0, ... (0, in binary 0, has no runs (by convention), thus at first we have all-0 sequence)
1, 0, 0, 0, 0, ... (1, in binary 1, has one run of length 1)
1, 1, 0, 0, 0, ... (2, in binary 10, has two runs of length 1 both)
2, 0, 0, 0, 0, ... (3, in binary 11, has one run of length 2)
2, 1, 0, 0, 0, ... (4, in binary 100, the rightmost run of length 2 given first, then the second run of length 1)
1, 1, 1, 0, 0, ... (5, in binary 101, has three runs of one bit each)
1, 2, 0, 0, 0, ...
3, 0, 0, 0, 0, ...
3, 1, 0, 0, 0, ...
1, 2, 1, 0, 0, ...
1, 1, 1, 1, 0, ...
2, 1, 1, 0, 0, ...
2, 2, 0, 0, 0, ...
1, 1, 2, 0, 0, ...
1, 3, 0, 0, 0, ...
4, 0, 0, 0, 0, ...
-
A227186 := 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) ;
a := 1 ;
for i from 2 to nops(bdgs) do
if op(i,bdgs) <> op(i-1,bdgs) then
if ru = k then
return a;
end if;
a := 1 ;
ru := ru+1 ;
else
a := a+1 ;
end if;
end do:
if ru =k then
a ;
else
0 ;
end if;
end proc: # R. J. Mathar, Jul 23 2013
-
A227186(n,k)=while(k>=0,for(c=1,n,bittest(n,0)==bittest(n\=2,0)&next;k&break;return(c));n||return;k--) \\ To let A(0,0)=1 add "!n||!" in front of while(...). TO DO: add default value k=-1 and implement "flattened" sequence, such that A227186(n) yields a(n). M. Hasler, Jul 21 2013
-
(define (A227186 n) (A227186bi (A002262 n) (A025581 n)))
(define (A227186bi n k) (cond ((< (A005811 n) (+ 1 k)) 0) ((zero? k) (A136480 n)) (else (A227186bi (A163575 n) (- k 1)))))
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))))))
A341694
Square array T(n, k) read by antidiagonals upwards, n, k > 0: T(n, k) = A227736(n, k) for k = 1..A005811(n), and T(n, k) = T(n, k - A005811(n)) + ... + T(n, k-1) for k > A005811(n).
Original entry on oeis.org
1, 1, 1, 2, 1, 1, 2, 2, 2, 1, 1, 1, 2, 3, 1, 1, 1, 3, 2, 5, 1, 3, 2, 1, 4, 2, 8, 1, 3, 3, 3, 3, 7, 2, 13, 1, 1, 1, 3, 5, 5, 11, 2, 21, 1, 1, 2, 4, 3, 8, 9, 18, 2, 34, 1, 2, 1, 1, 5, 3, 13, 17, 29, 2, 55, 1, 2, 1, 1, 4, 9, 3, 21, 31, 47, 2, 89, 1
Offset: 1
Array T(n, k) begins:
n\k| 1 2 3 4 5 6 7 8 9 10 11 12 13 14
---+---------------------------------------------------------
1| 1 1 1 1 1 1 1 1 1 1 1 1 1 1 --> A000012
2| 1 1 2 3 5 8 13 21 34 55 89 144 233 377 --> A000045
3| 2 2 2 2 2 2 2 2 2 2 2 2 2 2 --> A007395
4| 2 1 3 4 7 11 18 29 47 76 123 199 322 521 --> A000032
5| 1 1 1 3 5 9 17 31 57 105 193 355 653 1201 --> A000213
6| 1 2 3 5 8 13 21 34 55 89 144 233 377 610 --> A000045
7| 3 3 3 3 3 3 3 3 3 3 3 3 3 3 --> A010701
8| 3 1 4 5 9 14 23 37 60 97 157 254 411 665 --> A104449
9| 1 2 1 4 7 12 23 42 77 142 261 480 883 1624 --> A275778
10| 1 1 1 1 4 7 13 25 49 94 181 349 673 1297 --> A000288
A092054
Base-2 logarithm of the sum of numerator and denominator of the convergents of the continued fraction expansion [1; 1/2, 1/3, 1/4, ..., 1/n, ...].
Original entry on oeis.org
1, 2, 4, 6, 7, 8, 11, 14, 15, 16, 18, 20, 21, 22, 26, 30, 31, 32, 34, 36, 37, 38, 41, 44, 45, 46, 48, 50, 51, 52, 57, 62, 63, 64, 66, 68, 69, 70, 73, 76, 77, 78, 80, 82, 83, 84, 88, 92, 93, 94, 96, 98, 99, 100, 103, 106, 107, 108, 110, 112, 113, 114, 120, 126, 127, 128, 130
Offset: 1
a(4)=6 since [1; 1/2, 1/3, 1/4] = 1 + 1/(1/2 + 1/(1/3 + 1/(1/4))) = 45/19; and the sum of the numerator and denominator of 45/19 equals 45 + 19 = 2^6.
-
{a(n)=local(A);CF=contfracpnqn(vector(n,k,1/k)); A=length(binary(numerator(1+CF[1,1]/CF[2,1])))-1}
A336962
Right-rotate run-lengths of consecutive equal digits in binary representation of n.
Original entry on oeis.org
0, 1, 2, 3, 6, 5, 4, 7, 14, 11, 10, 13, 12, 9, 8, 15, 30, 23, 22, 27, 26, 21, 20, 29, 28, 19, 18, 25, 24, 17, 16, 31, 62, 47, 46, 55, 54, 45, 44, 59, 58, 43, 42, 53, 52, 41, 40, 61, 60, 39, 38, 51, 50, 37, 36, 57, 56, 35, 34, 49, 48, 33, 32, 63, 126, 95, 94
Offset: 0
The first terms, in decimal and in binary, are:
n a(n) bin(n) bin(a(n))
-- ---- ------ ---------
0 0 0 0
1 1 1 1
2 2 10 10
3 3 11 11
4 6 100 110
5 5 101 101
6 4 110 100
7 7 111 111
8 14 1000 1110
9 11 1001 1011
10 10 1010 1010
11 13 1011 1101
12 12 1100 1100
13 9 1101 1001
14 8 1110 1000
15 15 1111 1111
-
toruns(n) = { my (r=[]); while (n, my (v=valuation(n+n%2,2)); n\=2^v; r=concat(v,r)); r }
fromruns(r) = { my (v=0); for (k=1, #r, v=(v+k%2)*2^r[k]-k%2); v }
a(n) = { my (r=toruns(n)); fromruns(vector(#r, k, r[1+(k-2)%#r])) }
A361670
Squarefree part of the n-th triangular number.
Original entry on oeis.org
1, 3, 6, 10, 15, 21, 7, 1, 5, 55, 66, 78, 91, 105, 30, 34, 17, 19, 190, 210, 231, 253, 69, 3, 13, 39, 42, 406, 435, 465, 31, 33, 561, 595, 70, 74, 703, 741, 195, 205, 861, 903, 946, 110, 115, 1081, 282, 6, 1, 51, 1326, 1378, 159, 165, 385, 399, 1653, 1711, 1770, 1830, 1891, 217, 14, 130, 2145, 2211, 2278
Offset: 1
-
a:= n-> mul(i[1]^irem(i[2], 2), i=ifactors(n*(n+1)/2)[2]):
seq(a(n), n=1..70); # Alois P. Heinz, Mar 20 2023
-
a(n) = core(n*(n+1)/2); \\ Michel Marcus, Mar 22 2023
-
from sympy.ntheory.factor_ import core
def A361670(n): return core(n*(n+1)>>1) # Chai Wah Wu, Mar 20 2023
A344346
Numbers k which have an odd number of trailing zeros in their binary reflected Gray code A014550(k).
Original entry on oeis.org
3, 4, 11, 12, 15, 16, 19, 20, 27, 28, 35, 36, 43, 44, 47, 48, 51, 52, 59, 60, 63, 64, 67, 68, 75, 76, 79, 80, 83, 84, 91, 92, 99, 100, 107, 108, 111, 112, 115, 116, 123, 124, 131, 132, 139, 140, 143, 144, 147, 148, 155, 156, 163, 164, 171, 172, 175, 176, 179, 180
Offset: 1
3 is a term since its Gray code, 10, has 1 trailing zero, and 1 is odd.
15 is a term since its Gray code, 1000, has 3 trailing zeros, and 3 is odd.
-
Select[Range[180], OddQ @ IntegerExponent[# * (# + 1)/2, 2] &]
-
def A344346(n):
def f(x):
c, s = (n+1>>1)+x, bin(x)[2:]
l = len(s)
for i in range(l&1^1,l,2):
c -= int(s[i])+int('0'+s[:i],2)
return c
m, k = n, f(n)
while m != k: m, k = k, f(k)
return (m<<2)-(n&1) # Chai Wah Wu, Jan 29 2025
A378992
a(n) = A011371(n) - A048881(n); The exponent of the highest power of 2 dividing the n-th factorial minus the exponent of the highest power of 2 dividing n-th Catalan number.
Original entry on oeis.org
0, 0, 0, 1, 2, 2, 2, 4, 6, 6, 6, 7, 8, 8, 8, 11, 14, 14, 14, 15, 16, 16, 16, 18, 20, 20, 20, 21, 22, 22, 22, 26, 30, 30, 30, 31, 32, 32, 32, 34, 36, 36, 36, 37, 38, 38, 38, 41, 44, 44, 44, 45, 46, 46, 46, 48, 50, 50, 50, 51, 52, 52, 52, 57, 62, 62, 62, 63, 64, 64, 64, 66, 68, 68, 68, 69, 70, 70, 70, 73, 76, 76, 76
Offset: 0
-
A378992[n_] := n - DigitCount[n, 2, 1] - DigitCount[n + 1, 2, 1] + 1;
Array[A378992, 100, 0] (* or *)
MapIndexed[#2[[1]] - # &, Total[Partition[DigitCount[Range[0, 100], 2, 1], 2, 1], {2}]] (* Paolo Xausa, Dec 28 2024 *)
-
A378992(n) = (1+(n-hammingweight(n)-hammingweight(1+n)));
Comments