A227349
Product of lengths of runs of 1-bits in binary representation of n.
Original entry on oeis.org
1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 4, 1, 1, 1, 2, 1, 1, 2, 3, 2, 2, 2, 4, 3, 3, 4, 5, 1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 4, 2, 2, 2, 4, 2, 2, 4, 6, 3, 3, 3, 6, 4, 4, 5, 6, 1, 1, 1, 2, 1, 1, 2, 3, 1, 1, 1, 2, 2, 2, 3, 4, 1, 1, 1, 2, 1, 1, 2, 3, 2, 2, 2, 4, 3, 3, 4, 5, 2, 2, 2, 4, 2, 2, 4, 6, 2, 2, 2, 4, 4, 4, 6, 8, 3, 3, 3, 6, 3, 3, 6, 9, 4
Offset: 0
a(0) = 1, as zero has no runs of 1's, and an empty product is 1.
a(1) = 1, as 1 is "1" in binary, and the length of that only 1-run is 1.
a(2) = 1, as 2 is "10" in binary, and again there is only one run of 1-bits, of length 1.
a(3) = 2, as 3 is "11" in binary, and there is one run of two 1-bits.
a(55) = 6, as 55 is "110111" in binary, and 2 * 3 = 6.
a(119) = 9, as 119 is "1110111" in binary, and 3 * 3 = 9.
From _Omar E. Pol_, Feb 10 2015: (Start)
Written as an irregular triangle in which row lengths is A011782:
1;
1;
1,2;
1,1,2,3;
1,1,1,2,2,2,3,4;
1,1,1,2,1,1,2,3,2,2,2,4,3,3,4,5;
1,1,1,2,1,1,2,3,1,1,1,2,2,2,3,4,2,2,2,4,2,2,4,6,3,3,3,6,4,4,5,6;
...
Right border gives A028310: 1 together with the positive integers. (End)
From _Omar E. Pol_, Mar 19 2015: (Start)
Also, the sequence can be written as an irregular tetrahedron T(s, r, k) as shown below:
1;
..
1;
..
1;
2;
....
1,1;
2;
3;
........
1,1,1,2;
2,2;
3;
4;
................
1,1,1,2,1,1,2,3;
2,2,2,4;
3,3;
4;
5;
................................
1,1,1,2,1,1,2,3,1,1,1,2,2,2,3,4;
2,2,2,4,2,2,4,6;
3,3,3,6;
4,4;
5;
6;
...
Apart from the initial 1, we have that T(s, r, k) = T(s+1, r, k). (End)
Cf.
A000120 (sum of lengths of runs of 1-bits),
A167489,
A227350,
A227193,
A278222,
A245562,
A284562,
A284569,
A283972,
A284582,
A284583.
Differs from similar
A284580 for the first time at n=119, where a(119) = 9, while
A284580(119) = 5.
-
a:= proc(n) local i, m, r; m, r:= n, 1;
while m>0 do
while irem(m, 2, 'h')=0 do m:=h od;
for i from 0 while irem(m, 2, 'h')=1 do m:=h od;
r:= r*i
od; r
end:
seq(a(n), n=0..100); # Alois P. Heinz, Jul 11 2013
ans:=[];
for n from 0 to 100 do lis:=[]; t1:=convert(n, base, 2); L1:=nops(t1); out1:=1; c:=0;
for i from 1 to L1 do
if out1 = 1 and t1[i] = 1 then out1:=0; c:=c+1;
elif out1 = 0 and t1[i] = 1 then c:=c+1;
elif out1 = 1 and t1[i] = 0 then c:=c;
elif out1 = 0 and t1[i] = 0 then lis:=[c, op(lis)]; out1:=1; c:=0;
fi;
if i = L1 and c>0 then lis:=[c, op(lis)]; fi;
od:
a:=mul(i, i in lis);
ans:=[op(ans), a];
od:
ans; # N. J. A. Sloane, Sep 05 2014
-
onBitRunLenProd[n_] := Times @@ Length /@ Select[Split @ IntegerDigits[n, 2], #[[1]] == 1 & ]; Array[onBitRunLenProd, 100, 0] (* Jean-François Alcover, Mar 02 2016 *)
-
from operator import mul
from functools import reduce
from re import split
def A227349(n):
return reduce(mul, (len(d) for d in split('0+',bin(n)[2:]) if d)) if n > 0 else 1 # Chai Wah Wu, Sep 07 2014
-
# uses[RLT from A246660]
A227349_list = lambda len: RLT(lambda n: n, len)
A227349_list(88) # Peter Luschny, Sep 07 2014
-
(define (A227349 n) (apply * (bisect (reverse (binexp->runcount1list n)) (- 1 (modulo n 2)))))
(define (bisect lista parity) (let loop ((lista lista) (i 0) (z (list))) (cond ((null? lista) (reverse! z)) ((eq? i parity) (loop (cdr lista) (modulo (1+ i) 2) (cons (car lista) z))) (else (loop (cdr lista) (modulo (1+ i) 2) z)))))
(define (binexp->runcount1list n) (if (zero? n) (list) (let loop ((n n) (rc (list)) (count 0) (prev-bit (modulo n 2))) (if (zero? n) (cons count rc) (if (eq? (modulo n 2) prev-bit) (loop (floor->exact (/ n 2)) rc (1+ count) (modulo n 2)) (loop (floor->exact (/ n 2)) (cons count rc) 1 (modulo n 2)))))))
A003726
Numbers with no 3 adjacent 1's in binary expansion.
Original entry on oeis.org
0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 27, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 43, 44, 45, 48, 49, 50, 51, 52, 53, 54, 64, 65, 66, 67, 68, 69, 70, 72, 73, 74, 75, 76, 77, 80, 81, 82
Offset: 1
-
a003726 n = a003726_list !! (n - 1)
a003726_list = filter f [0..] where
f x = x < 7 || (x `mod` 8) < 7 && f (x `div` 2)
-- Reinhard Zumkeller, Jun 03 2012
-
Select[Range[0, 82], SequenceCount[IntegerDigits[#, 2], {1, 1, 1}] == 0 &] (* Michael De Vlieger, Dec 23 2019 *)
-
is(n)=!bitand(bitand(n, n<<1), n<<2) \\ Charles R Greathouse IV, Feb 11 2017
A087808
a(0) = 0; a(2n) = 2a(n), a(2n+1) = a(n) + 1.
Original entry on oeis.org
0, 1, 2, 2, 4, 3, 4, 3, 8, 5, 6, 4, 8, 5, 6, 4, 16, 9, 10, 6, 12, 7, 8, 5, 16, 9, 10, 6, 12, 7, 8, 5, 32, 17, 18, 10, 20, 11, 12, 7, 24, 13, 14, 8, 16, 9, 10, 6, 32, 17, 18, 10, 20, 11, 12, 7, 24, 13, 14, 8, 16, 9, 10, 6, 64, 33, 34, 18, 36, 19, 20, 11, 40, 21, 22, 12
Offset: 0
This is Guy Steele's sequence GS(5, 4) (see
A135416); compare GS(4, 5):
A135529.
A048678(k) is where k appears first in the sequence.
-
import Data.List (transpose)
a087808 n = a087808_list !! n
a087808_list = 0 : concat
(transpose [map (+ 1) a087808_list, map (* 2) $ tail a087808_list])
-- Reinhard Zumkeller, Mar 18 2015
-
S := 2; f := proc(n) global S; option remember; if n=0 then RETURN(0); fi; if n mod 2 = 0 then RETURN(S*f(n/2)); else f((n-1)/2)+1; fi; end;
-
a[0]=0; a[n_] := a[n] = If[EvenQ[n], 2*a[n/2], a[(n-1)/2]+1]; Array[a,76,0] (* Jean-François Alcover, Aug 12 2017 *)
-
a(n)=if(n<1,0,if(n%2==0,2*a(n/2),a((n-1)/2)+1))
-
from functools import lru_cache
@lru_cache(maxsize=None)
def A087808(n): return 0 if n == 0 else A087808(n//2) + (1 if n % 2 else A087808(n//2)) # Chai Wah Wu, Mar 08 2022
-
(define (A087808 n) (cond ((zero? n) n) ((even? n) (* 2 (A087808 (/ n 2)))) (else (+ 1 (A087808 (/ (- n 1) 2)))))) ;; Antti Karttunen, Oct 07 2016
A372433
Binary weight (number of ones in binary expansion) of the n-th squarefree number.
Original entry on oeis.org
1, 1, 2, 2, 2, 3, 2, 3, 3, 3, 4, 2, 3, 3, 3, 4, 3, 4, 4, 5, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 5, 4, 4, 5, 4, 4, 5, 5, 5, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 5, 3, 4, 4, 4, 5, 4, 5, 5, 5, 6, 3, 4, 4, 5, 4, 4, 5, 5, 5, 6, 4, 4, 5, 5, 6, 5, 6, 7, 2, 2, 3, 3, 3, 3, 3, 4, 4
Offset: 1
For binary length instead of weight we have
A372475.
A003714 lists numbers with no successive binary indices.
A048793 lists positions of ones in reversed binary expansion, sum
A029931.
A372515 lists positions of zeros in reversed binary expansion, sum
A359400.
-
DigitCount[Select[Range[100],SquareFreeQ],2,1]
Total[IntegerDigits[#,2]]&/@Select[Range[200],SquareFreeQ] (* Harvey P. Dale, Feb 14 2025 *)
-
from math import isqrt
from sympy import mobius
def A372433(n):
def f(x): return n+x-sum(mobius(k)*(x//k**2) for k in range(1, isqrt(x)+1))
m, k = n, f(n)
while m != k:
m, k = k, f(k)
return int(m).bit_count() # Chai Wah Wu, Aug 02 2024
A039004
Numbers whose base-4 representation has the same number of 1's and 2's.
Original entry on oeis.org
0, 3, 6, 9, 12, 15, 18, 24, 27, 30, 33, 36, 39, 45, 48, 51, 54, 57, 60, 63, 66, 72, 75, 78, 90, 96, 99, 102, 105, 108, 111, 114, 120, 123, 126, 129, 132, 135, 141, 144, 147, 150, 153, 156, 159, 165, 177, 180, 183, 189, 192, 195, 198, 201, 204, 207, 210, 216, 219
Offset: 1
A subset of
A001969 (evil numbers).
A base-2 version is
A031443 (digitally balanced numbers).
Positions of first appearances are
A086893.
The version for standard compositions is
A344619.
A003714 lists numbers with no successive binary indices.
A030190 gives the binary expansion of each nonnegative integer.
A070939 gives the length of an integer's binary expansion.
A097805 counts compositions by alternating (or reverse-alternating) sum.
A101211 lists run-lengths in binary expansion:
A138364 counts compositions with alternating sum 0:
A328594 lists numbers whose binary expansion is aperiodic.
A345197 counts compositions by length and alternating sum.
-
c See link in A139351.
-
N:= 1000: # to get all terms up to N, which should be divisible by 4
B:= Array(0..N-1):
d:= ceil(log[4](N));
S:= Array(0..N-1,[seq(op([0,1,-1,0]),i=1..N/4)]):
for i from 1 to d do
B:= B + S;
S:= Array(0..N-1,i-> S[floor(i/4)]);
od:
select(t -> B[t]=0, [$0..N-1]); # Robert Israel, Jun 24 2015
-
ats[y_]:=Sum[(-1)^(i-1)*y[[i]],{i,Length[y]}];
Select[Range[0,100],ats[IntegerDigits[#,2]]==0&] (* Gus Wiseman, Jul 28 2021 *)
-
for(n=0,219,if(sum(i=1,length(binary(n)),(-1)^i*component(binary(n),i))==0,print1(n,",")))
A359359
Sum of positions of zeros in the binary expansion of n, where positions are read starting with 1 from the left (big-endian).
Original entry on oeis.org
1, 0, 2, 0, 5, 2, 3, 0, 9, 5, 6, 2, 7, 3, 4, 0, 14, 9, 10, 5, 11, 6, 7, 2, 12, 7, 8, 3, 9, 4, 5, 0, 20, 14, 15, 9, 16, 10, 11, 5, 17, 11, 12, 6, 13, 7, 8, 2, 18, 12, 13, 7, 14, 8, 9, 3, 15, 9, 10, 4, 11, 5, 6, 0, 27, 20, 21, 14, 22, 15, 16, 9, 23, 16, 17, 10
Offset: 0
The binary expansion of 100 is (1,1,0,0,1,0,0), with zeros at positions {3,4,6,7}, so a(100) = 20.
A003714 lists numbers with no successive binary indices.
Cf.
A000120,
A048793,
A065359,
A069010,
A070939,
A073642,
A083652,
A328594,
A328595,
A359402,
A359495.
-
Table[Total[Join@@Position[IntegerDigits[n,2],0]],{n,0,100}]
A060142
Ordered set S defined by these rules: 0 is in S and if x is in S then 2x+1 and 4x are in S.
Original entry on oeis.org
0, 1, 3, 4, 7, 9, 12, 15, 16, 19, 25, 28, 31, 33, 36, 39, 48, 51, 57, 60, 63, 64, 67, 73, 76, 79, 97, 100, 103, 112, 115, 121, 124, 127, 129, 132, 135, 144, 147, 153, 156, 159, 192, 195, 201, 204, 207, 225, 228, 231, 240, 243, 249, 252, 255, 256, 259, 265, 268, 271
Offset: 0
From _Harry Richman_, Jan 31 2024: (Start)
In the following, dots are used for zeros in the binary representation:
n binary(a(n)) a(n)
0: ....... 0
1: ......1 1
2: .....11 3
3: ....1.. 4
4: ....111 7
5: ...1..1 9
6: ...11.. 12
7: ...1111 15
8: ..1.... 16
9: ..1..11 19
10: ..11..1 25
11: ..111.. 28
12: ..11111 31
13: .1....1 33
14: .1..1.. 36
15: .1..111 39
16: .11.... 48
17: .11..11 51
18: .111..1 57
19: .1111.. 60
20: .111111 63
21: 1...... 64
22: 1....11 67
(End)
- Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
- Clark Kimberling, A Self-Generating Set and the Golden Mean, J. Integer Sequences, 3 (2000), #00.2.8.
- Clark Kimberling, Fusion, Fission, and Factors, Fib. Q., 52 (2014), 195-202.
- Lukasz Merta, Composition inverses of the variations of the Baum-Sweet sequence, arXiv:1803.00292 [math.NT], 2018. See l(n) p. 5.
- Gus Wiseman, Statistics, classes, and transformations of standard compositions
Cf.
A003714 (no consecutive 1's in binary expansion).
Odd partitions are counted by
A000009.
Numbers with an odd number of 1's in binary expansion are
A000069.
Numbers whose binary expansion has odd length are
A053738.
All of the following pertain to compositions in standard order (
A066099):
- Compositions without odd parts are
A062880.
- Number of distinct parts is
A334028.
-
import Data.Set (singleton, deleteFindMin, insert)
a060142 n = a060142_list !! n
a060142_list = 0 : f (singleton 1) where
f s = x : f (insert (4 * x) $ insert (2 * x + 1) s') where
(x, s') = deleteFindMin s
-- Reinhard Zumkeller, Nov 26 2012
-
Take[Nest[Union[Flatten[# /. {{i_Integer -> i}, {i_Integer -> 2 i + 1}, {i_Integer -> 4 i}}]] &, {1}, 5], 32] (* Or *)
Select[Range[124], FreeQ[Length /@ Select[Split[IntegerDigits[#, 2]], First[#] == 0 &], ?OddQ] &] (* _Birkas Gyorgy, May 29 2012 *)
-
is(n)=if(n<3, n<2, if(n%2,is(n\2),n%4==0 && is(n/4))) \\ Charles R Greathouse IV, Oct 21 2013
A359400
Sum of positions of zeros in the reversed binary expansion of n, where positions in a sequence are read starting with 1 from the left.
Original entry on oeis.org
1, 0, 1, 0, 3, 2, 1, 0, 6, 5, 4, 3, 3, 2, 1, 0, 10, 9, 8, 7, 7, 6, 5, 4, 6, 5, 4, 3, 3, 2, 1, 0, 15, 14, 13, 12, 12, 11, 10, 9, 11, 10, 9, 8, 8, 7, 6, 5, 10, 9, 8, 7, 7, 6, 5, 4, 6, 5, 4, 3, 3, 2, 1, 0, 21, 20, 19, 18, 18, 17, 16, 15, 17, 16, 15, 14, 14, 13
Offset: 0
The reversed binary expansion of 100 is (0,0,1,0,0,1,1), with zeros at positions {1,2,4,5}, so a(100) = 12.
The non-reversed version is
A359359.
A003714 lists numbers with no successive binary indices.
-
long A359400(long n) {
long result = 0, counter = 1;
do {
if (n % 2 == 0)
result += counter;
counter++;
n /= 2;
} while (n > 0);
return result; } // Frank Hollstein, Jan 06 2023
-
Table[Total[Join@@Position[Reverse[IntegerDigits[n,2]],0]],{n,0,100}]
-
def a(n): return sum(i for i, bi in enumerate(bin(n)[:1:-1], 1) if bi=='0')
print([a(n) for n in range(78)]) # Michael S. Branicky, Jan 09 2023
A107907
Numbers having consecutive zeros or consecutive ones in binary representation.
Original entry on oeis.org
3, 4, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77
Offset: 1
From _Gus Wiseman_, Nov 27 2019: (Start)
The sequence of terms together with their binary expansions begins:
3: 11
4: 100
6: 110
7: 111
8: 1000
9: 1001
11: 1011
12: 1100
13: 1101
14: 1110
15: 1111
16: 10000
17: 10001
18: 10010
(End)
-
Select[Range[100],MatchQ[IntegerDigits[#,2],{_,x_,x_,_}]&] (* Gus Wiseman, Nov 27 2019 *)
Select[Range[80],SequenceCount[IntegerDigits[#,2],{x_,x_}]>0&] (* or *) Complement[Range[85],Table[FromDigits[PadRight[{},n,{1,0}],2],{n,7}]] (* Harvey P. Dale, Jul 31 2021 *)
-
def A107907(n): return (m:=n-2+(k:=(3*n+3).bit_length()))+(m>=(1<Chai Wah Wu, Apr 21 2025
A372475
Length of binary expansion (or number of bits) of the n-th squarefree number.
Original entry on oeis.org
1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8
Offset: 1
The 10th squarefree number is 14, with binary expansion (1,1,1,0), so a(10) = 4.
Positions of first appearances are
A372540.
A048793 lists positions of ones in reversed binary expansion, sum
A029931.
A372515 lists positions of zeros in reversed binary expansion, sum
A359400.
Cf.
A003714,
A023416,
A049093,
A049094,
A059015,
A069010,
A073642,
A145037,
A211997,
A368494,
A372474,
A372516.
-
IntegerLength[Select[Range[1000],SquareFreeQ],2]
-
from math import isqrt
from sympy import mobius
def A372475(n):
def f(x): return n+x-sum(mobius(k)*(x//k**2) for k in range(1, isqrt(x)+1))
m, k = n, f(n)
while m != k:
m, k = k, f(k)
return int(m).bit_length() # Chai Wah Wu, Aug 02 2024
Comments