cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

Showing 1-10 of 19 results. Next

A366600 a(n) = (1 + A033264(n))*a(A053645(n)) for n > 0 with a(0) = 1.

Original entry on oeis.org

1, 1, 2, 1, 2, 2, 4, 1, 2, 2, 6, 2, 4, 4, 8, 1, 2, 2, 6, 2, 6, 6, 12, 2, 4, 4, 18, 4, 8, 8, 16, 1, 2, 2, 6, 2, 6, 6, 12, 2, 6, 6, 24, 6, 12, 12, 24, 2, 4, 4, 18, 4, 18, 18, 36, 4, 8, 8, 54, 8, 16, 16, 32, 1, 2, 2, 6, 2, 6, 6, 12, 2, 6, 6, 24, 6, 12, 12, 24, 2
Offset: 0

Views

Author

Mikhail Kurkov, Oct 14 2023

Keywords

Examples

			a(6) = 4 because the binary expansion of 6 is 110 and we have [(10), 1(10)] -> [1, 1]. Increasing these values by 1 gives us 2*2 = 4.
a(18) = 6 because the binary expansion of 18 is 10010 and we have [(10), (10)0(10)] -> [1, 2]. Increasing these values by 1 gives us 2*3 = 6.
a(26) = 18 because the binary expansion of 26 is 11010 and we have [(10), (10)(10), 1(10)(10)] -> [1, 2, 2]. Increasing these values by 1 gives us 2*3*3 = 18.
For n=482, the bits of n and the resulting product for a(n) are
  n    = 482 = binary 1 1 1 1 0 0 0 1 0
  a(n) = 162 =        3*3*3*3      *2
n=3863 = binary 111100010111 is the same a(n) = 162 since its final trailing "111" has no effect.
		

Crossrefs

Programs

  • Mathematica
    A033264[n_] := SequenceCount[IntegerDigits[n, 2], {1, 0}];
    A053645[n_] := n - 2^Floor@Log2@n;
    a[n_] := a[n] = If[n == 0, 1, (1 + A033264[n]) a[A053645[n]]];
    Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Nov 14 2023 *)
  • PARI
    a(n) = my(A = 1, B = 1); if(n, for(i=1, logint(n, 2), if(bittest(n, i), A *= (B += !bittest(n, i-1))))); A

Formula

a(2n + 1) = a(n).
a(4n) = a(2n) with a(0) = 1.
a(4n + 2) = 2*b(n), b(2n + 1) = 2*b(n), b(2n) = 3*c(n - 1, 1) with b(0) = 1.
c(2n + 1, k) = c(n, k), c(4n + 2, k) = (k + 2)*c(2n, k), c(4n, k) = (k + 3)*c(n - 1, k + 1) with c(0, k) = 1.
Another way to compute a(4n + 2):
a(2*(4^n - 1)/3) = (n + 1)!.
a(2^(2m)*(2k + 1) + 2*(4^m - 1)/3) = (m + 1)*a(2^(2m)*k + 2*(4^m - 1)/3).
a(2^(2m + 1)*(2k + 1) + 2*(4^(m + 1) - 1)/3) = a(2^(2m + 1)*k + 2*(4^(m + 1) - 1)/3).
Note that a(4n + 2) is completely defined by these 3 last formulas. However, it looks like that it is not so easy to identify m and k for a given n, which makes these formulas useless for computing this sequence.

A005811 Number of runs in binary expansion of n (n>0); number of 1's in Gray code for n.

Original entry on oeis.org

0, 1, 2, 1, 2, 3, 2, 1, 2, 3, 4, 3, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 4, 3, 2, 3, 4, 3, 4, 5, 4, 3, 2, 3, 4, 3, 2, 3, 2, 1, 2, 3, 4, 3, 4, 5, 4, 3, 4, 5, 6, 5, 4, 5, 4, 3, 4, 5, 6, 5, 6, 7, 6, 5, 4, 5, 6, 5, 4, 5
Offset: 0

Views

Author

Keywords

Comments

Starting with a(1) = 0 mirror all initial 2^k segments and increase by one.
a(n) gives the net rotation (measured in right angles) after taking n steps along a dragon curve. - Christopher Hendrie (hendrie(AT)acm.org), Sep 11 2002
This sequence generates A082410: (0, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, ...) and A014577; identical to the latter except starting 1, 1, 0, ...; by writing a "1" if a(n+1) > a(n); if not, write "0". E.g., A014577(2) = 0, since a(3) < a(2), or 1 < 2. - Gary W. Adamson, Sep 20 2003
Starting with 1 = partial sums of A034947: (1, 1, -1, 1, 1, -1, -1, 1, 1, 1, ...). - Gary W. Adamson, Jul 23 2008
The composer Per Nørgård's name is also written in the OEIS as Per Noergaard.
Can be used as a binomial transform operator: Let a(n) = the n-th term in any S(n); then extract 2^k strings, adding the terms. This results in the binomial transform of S(n). Say S(n) = 1, 3, 5, ...; then we obtain the strings: (1), (3, 1), (3, 5, 3, 1), (3, 5, 7, 5, 3, 5, 3, 1), ...; = the binomial transform of (1, 3, 5, ...) = (1, 4, 12, 32, 80, ...). Example: the 8-bit string has a sum of 32 with a distribution of (1, 3, 3, 1) or one 1, three 3's, three 5's, and one 7; as expected. - Gary W. Adamson, Jun 21 2012
Considers all positive odd numbers as nodes of a graph. Two nodes are connected if and only if the sum of the two corresponding odd numbers is a power of 2. Then a(n) is the distance between 2n + 1 and 1. - Jianing Song, Apr 20 2019

Examples

			Considered as a triangle with 2^k terms per row, the first few rows are:
  1
  2, 1
  2, 3, 2, 1
  2, 3, 4, 3, 2, 3, 2, 1
  ...
The n-th row becomes right half of next row; left half is mirrored terms of n-th row increased by one. - _Gary W. Adamson_, Jun 20 2012
		

References

  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Cf. A037834 (-1), A088748 (+1), A246960 (mod 4), A034947 (first differences), A000975 (indices of record highs), A173318 (partial sums).
Partial sums of A112347. Recursion depth of A035327.

Programs

  • Haskell
    import Data.List (group)
    a005811 0 = 0
    a005811 n = length $ group $ a030308_row n
    a005811_list = 0 : f [1] where
       f (x:xs) = x : f (xs ++ [x + x `mod` 2, x + 1 - x `mod` 2])
    -- Reinhard Zumkeller, Feb 16 2013, Mar 07 2011
    
  • Maple
    A005811 := proc(n)
        local i, b, ans;
        if n = 0 then
            return 0 ;
        end if;
        ans := 1;
        b := convert(n, base, 2);
        for i from nops(b)-1 to 1 by -1 do
            if b[ i+1 ]<>b[ i ] then
                ans := ans+1
            fi
        od;
        return ans ;
    end proc:
    seq(A005811(i), i=1..50) ;
    # second Maple program:
    a:= n-> add(i, i=Bits[Split](Bits[Xor](n, iquo(n, 2)))):
    seq(a(n), n=0..100);  # Alois P. Heinz, Feb 01 2023
  • Mathematica
    Table[ Length[ Length/@Split[ IntegerDigits[ n, 2 ] ] ], {n, 1, 255} ]
    a[n_] := DigitCount[BitXor[n, Floor[n/2]], 2, 1]; Array[a, 100, 0] (* Amiram Eldar, Jul 11 2024 *)
  • PARI
    a(n)=sum(k=1,n,(-1)^((k/2^valuation(k,2)-1)/2))
    
  • PARI
    a(n)=if(n<1,0,a(n\2)+(a(n\2)+n)%2) \\ Benoit Cloitre, Jan 20 2014
    
  • PARI
    a(n) = hammingweight(bitxor(n, n>>1));  \\ Gheorghe Coserea, Sep 03 2015
    
  • Python
    def a(n): return bin(n^(n>>1))[2:].count("1") # Indranil Ghosh, Apr 29 2017

Formula

a(2^k + i) = a(2^k - i + 1) + 1 for k >= 0 and 0 < i <= 2^k. - Reinhard Zumkeller, Aug 14 2001
a(2n+1) = 2a(n) - a(2n) + 1, a(4n) = a(2n), a(4n+2) = 1 + a(2n+1).
a(j+1) = a(j) + (-1)^A014707(j). - Christopher Hendrie (hendrie(AT)acm.org), Sep 11 2002
G.f.: (1/(1-x)) * Sum_{k>=0} x^2^k/(1+x^2^(k+1)). - Ralf Stephan, May 02 2003
Delete the 0, make subsets of 2^n terms; and reverse the terms in each subset to generate A088696. - Gary W. Adamson, Oct 19 2003
a(0) = 0, a(2n) = a(n) + [n odd], a(2n+1) = a(n) + [n even]. - Ralf Stephan, Oct 20 2003
a(n) = Sum_{k=1..n} (-1)^((k/2^A007814(k)-1)/2) = Sum_{k=1..n} (-1)^A025480(k-1). - Ralf Stephan, Oct 29 2003
a(n) = A069010(n) + A033264(n). - Ralf Stephan, Oct 29 2003
a(0) = 0 then a(n) = a(floor(n/2)) + (a(floor(n/2)) + n) mod 2. - Benoit Cloitre, Jan 20 2014
a(n) = A037834(n) + 1.
a(n) = A000120(A003188(n)). - Amiram Eldar, Jul 11 2024

Extensions

Additional description from Wouter Meeussen

A069010 Number of runs of 1's in the binary representation of n.

Original entry on oeis.org

0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 3, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3, 3, 2, 3, 2, 2, 1, 2, 2, 2, 2, 3, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3, 3, 2, 3, 2, 2, 2, 3, 3, 3, 3, 4, 3, 3, 2, 3, 3, 3, 2, 3
Offset: 0

Views

Author

Henry Bottomley, Apr 02 2002

Keywords

Comments

a(n) is also the number of distinct parts in the integer partition having viabin number n. The viabin number of an integer partition is defined in the following way. Consider the southeast border of the Ferrers board of the integer partition and consider the binary number obtained by replacing each east step with 1 and each north step, except the last one, with 0. The corresponding decimal form is, by definition, the viabin number of the given integer partition. "Viabin" is coined from "via binary". For example, consider the integer partition [2,2,2,1]. The southeast border of its Ferrers board yields 10100, leading to the viabin number 20. - Emeric Deutsch, Jul 24 2017
Positions of first occurrences of k are A002450(k). - John Keith, Aug 30 2021

Examples

			a(11) = 2 since 11 is 1011 in binary with two runs of 1's.
a(12) = 1 since 12 is 1100 in binary with one run of 1's.
		

Crossrefs

Cf. A268411 (parity of the terms), A268412 (positions of even terms), A268415 (of odd terms).
Cf. A002450 (positions of record highs).
Cf. also A227349, A246588.

Programs

  • Maple
    f:= proc(n) option remember; if n::even then procname(n/2)
    elif n mod 4 = 1 then 1 + procname((n-1)/2) else  procname((n-1)/2) fi end proc:
    f(0):= 0:
    map(f, [$0..1000]); # Robert Israel, Sep 06 2015
  • Mathematica
    Count[Split@ IntegerDigits[#, 2], n_ /; First@ n == 1] & /@ Range[0, 120] (* Michael De Vlieger, Sep 05 2015 *)
  • PARI
    a(n) = (1 + (hammingweight(bitxor(n, n>>1)))) >> 1;  \\ Gheorghe Coserea, Sep 05 2015
    
  • Python
    def A069010(n):
        return sum(1 for d in bin(n)[2:].split('0') if len(d)) # Chai Wah Wu, Nov 04 2016
  • Scheme
    (define (A069010 n) (/ (+ (A005811 n) (A000035 n)) 2)) ;; Antti Karttunen, Feb 05 2016
    

Formula

a(n) = ceiling(A005811(n)/2) = A005811(n) - A033264(n). If 2^k <= n < 3*2^(k-1) then a(n) = a(n-2^k)+1; if 3*2^(k-1) <= n < 2^(k+1) then a(n) = a(n-2^k).
a(2n) = a(n), a(2n+1) = a(n) + [n is even]. - Ralf Stephan, Aug 20 2003
G.f.: (1/(1-x)) * Sum_{k>=0} (t/(1+t))/(1+t^2), where t=x^2^k. - Ralf Stephan, Sep 07 2003
a(n) = A000120(n) - A014081(n) = A037800(n) + 1, n>0. - Ralf Stephan, Sep 10 2003

A297330 Total variation of base-10 digits of n; see Comments.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 2, 1, 0, 1, 2, 3, 4, 5, 6, 7, 3, 2, 1, 0, 1, 2, 3, 4, 5, 6, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 6, 5, 4, 3, 2, 1, 0, 1, 2, 3, 7, 6, 5, 4, 3, 2, 1, 0, 1, 2, 8, 7, 6, 5, 4, 3, 2
Offset: 1

Views

Author

Clark Kimberling, Jan 17 2018

Keywords

Comments

Suppose that a number n has base-b digits b(m), b(m-1), ..., b(0). The base-b down-variation of n is the sum DV(n,b) of all d(i)-d(i-1) for which d(i) > d(i-1); the base-b up-variation of n is the sum UV(n,b) of all d(k-1)-d(k) for which d(k) < d(k-1). The total base-b variation of n is the sum TV(n,b) = DV(n,b) + UV(n,b). Guide to related sequences and partitions of the natural numbers:
***
Base b {DV(n,b)} {UV(n,b)} {TV(n,b)}
For each b, let u = {n : UV(n,b) < DV(n,b)}, e = {n : UV(n,b) = DV(n,b)}, and d = {n : UV(n,b) > DV(n,b)}. The sets u,e,d partition the natural numbers. A guide to the matching sequences for u, e, d follows:
***
Base b Sequence u Sequence e Sequence d
2 A005843 A005408 (none)
Not a duplicate of A151950: e.g., a(100)=1 but A151950(100)=11. - Robert Israel, Feb 06 2018

Examples

			13684632 has DV = 8-4 + 6-3 + 3-2 = 8 and has UV = 3-1 + 6-3 + 8-6 + 6-4 = 9, so that a(13684632) = DV + UV = 17.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local L,i; L:= convert(n,base,10);
    add(abs(L[i+1]-L[i]),i=1..nops(L)-1) end proc:
    map(f, [$1..100]); # Robert Israel, Feb 04 2018
    # alternative
    A297330 := proc(n)
        A037860(n)+A037851(n) ;
    end proc: # R. J. Mathar, Sep 27 2021
  • Mathematica
    b = 10; z = 120; t = Table[Total@Flatten@Map[Abs@Differences@# &, Partition[ IntegerDigits[n, b], 2, 1]], {n, z}] (* after Michael De Vlieger, e.g. A037834 *)
  • Python
    def A297330(n):
        s = str(n)
        return sum(abs(int(s[i])-int(s[i+1])) for i in range(len(s)-1)) # Chai Wah Wu, May 31 2022

A014081 a(n) is the number of occurrences of '11' in the binary expansion of n.

Original entry on oeis.org

0, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 1, 1, 1, 2, 3, 0, 0, 0, 1, 0, 0, 1, 2, 1, 1, 1, 2, 2, 2, 3, 4, 0, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 1, 1, 1, 2, 3, 1, 1, 1, 2, 1, 1, 2, 3, 2, 2, 2, 3, 3, 3, 4, 5, 0, 0, 0, 1, 0, 0, 1, 2, 0, 0, 0, 1, 1, 1, 2, 3, 0, 0, 0, 1, 0, 0, 1, 2, 1, 1, 1, 2, 2, 2, 3, 4, 1, 1, 1, 2, 1, 1, 2, 3, 1
Offset: 0

Views

Author

Keywords

Comments

a(n) takes the value k for the first time at n = 2^(k+1)-1. Cf. A000225. - Robert G. Wilson v, Apr 02 2009
a(n) = A213629(n,3) for n > 2. - Reinhard Zumkeller, Jun 17 2012

Examples

			The binary expansion of 15 is 1111, which contains three occurrences of 11, so a(15)=3.
		

Crossrefs

First differences give A245194.
A245195 gives 2^a(n).

Programs

  • Haskell
    import Data.Bits ((.&.))
    a014081 n = a000120 (n .&. div n 2)  -- Reinhard Zumkeller, Jan 23 2012
    
  • Maple
    # To count occurrences of 11..1 (k times) in binary expansion of v:
    cn := proc(v, k) local n, s, nn, i, j, som, kk;
    som := 0;
    kk := convert(cat(seq(1, j = 1 .. k)),string);
    n := convert(v, binary);
    s := convert(n, string);
    nn := length(s);
    for i to nn - k + 1 do
    if substring(s, i .. i + k - 1) = kk then som := som + 1 fi od;
    som; end; # This program no longer worked. Corrected by N. J. A. Sloane, Apr 06 2014.
    [seq(cn(n,2),n=0..300)];
    # Alternative:
    A014081 := proc(n) option remember;
      if n mod 4 <= 1 then procname(floor(n/4))
    elif n mod 4 = 2 then procname(n/2)
    else 1 + procname((n-1)/2)
    fi
    end proc:
    A014081(0):= 0:
    map(A014081, [$0..1000]); # Robert Israel, Sep 04 2015
  • Mathematica
    f[n_] := Count[ Partition[ IntegerDigits[n, 2], 2, 1], {1, 1}]; Table[ f@n, {n, 0, 104}] (* Robert G. Wilson v, Apr 02 2009 *)
    Table[SequenceCount[IntegerDigits[n,2],{1,1},Overlaps->True],{n,0,120}] (* Harvey P. Dale, Jun 06 2022 *)
  • PARI
    A014081(n)=sum(i=0,#binary(n)-2,bitand(n>>i,3)==3)  \\ M. F. Hasler, Jun 06 2012
    
  • PARI
    a(n) = hammingweight(bitand(n, n>>1)) ;
    vector(105, i, a(i-1))  \\ Gheorghe Coserea, Aug 30 2015
    
  • Python
    def a(n): return sum([((n>>i)&3==3) for i in range(len(bin(n)[2:]) - 1)]) # Indranil Ghosh, Jun 03 2017
    
  • Python
    from re import split
    def A014081(n): return sum(len(d)-1 for d in split('0+', bin(n)[2:]) if d != '') # Chai Wah Wu, Feb 04 2022

Formula

a(4n) = a(4n+1) = a(n), a(4n+2) = a(2n+1), a(4n+3) = a(2n+1) + 1. - Ralf Stephan, Aug 21 2003
G.f.: (1/(1-x)) * Sum_{k>=0} t^3/((1+t)*(1+t^2)), where t = x^(2^k). - Ralf Stephan, Sep 10 2003
a(n) = A000120(n) - A069010(n). - Ralf Stephan, Sep 10 2003
Sum_{n>=1} A014081(n)/(n*(n+1)) = A100046 (Allouche and Shallit, 1990). - Amiram Eldar, Jun 01 2021

A037800 Number of occurrences of 01 in the binary expansion of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2, 3, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 0, 1, 1, 1, 1, 2, 1
Offset: 0

Views

Author

Keywords

Comments

Number of i such that d(i)>d(i-1), where Sum{d(i)*2^i: i=0,1,...,m} is base 2 representation of n.
This is the base-2 up-variation sequence; see A297330. - Clark Kimberling, Jan 18 2017

Crossrefs

Programs

  • Haskell
    a037800 = f 0 . a030308_row where
       f c [_]          = c
       f c (1 : 0 : bs) = f (c + 1) bs
       f c (_ : bs)     = f c bs
    -- Reinhard Zumkeller, Feb 20 2014
    
  • Mathematica
    Table[SequenceCount[IntegerDigits[n,2],{0,1}],{n,0,120}] (* Harvey P. Dale, Aug 10 2023 *)
  • PARI
    a(n) = { if(n == 0, 0, -1 + hammingweight(bitnegimply(n, n>>1))) };  \\ Gheorghe Coserea, Aug 31 2015

Formula

a(2n) = a(n), a(2n+1) = a(n) + [n is even]. - Ralf Stephan, Aug 21 2003
G.f.: 1/(1-x) * Sum_{k>=0} t^5/(1+t)/(1+t^2) where t=x^2^k. - Ralf Stephan, Sep 10 2003
a(n) = A069010(n) - 1, n>0. - Ralf Stephan, Sep 10 2003
Sum_{n>=1} a(n)/(n*(n+1)) = log(2)/2 + Pi/4 - 1 = A231902 - 1 (Allouche and Shallit, 1990). - Amiram Eldar, Jun 01 2021

A278219 Filter-sequence related to base-2 run-length encoding: a(n) = A046523(A243353(n)).

Original entry on oeis.org

1, 2, 4, 2, 4, 8, 6, 2, 4, 12, 16, 8, 6, 12, 6, 2, 4, 12, 36, 12, 16, 32, 24, 8, 6, 30, 24, 12, 6, 12, 6, 2, 4, 12, 36, 12, 36, 72, 60, 12, 16, 48, 64, 32, 24, 72, 24, 8, 6, 30, 60, 30, 24, 48, 60, 12, 6, 30, 24, 12, 6, 12, 6, 2, 4, 12, 36, 12, 36, 72, 60, 12, 36, 180, 144, 72, 60, 180, 60, 12, 16, 48, 144, 48, 64, 128, 96, 32, 24, 120, 216, 72, 24, 72
Offset: 0

Views

Author

Antti Karttunen, Nov 16 2016

Keywords

Crossrefs

Other base-2 related filter sequences: A278217, A278222.
Sequences that (seem to) partition N into same or coarser equivalence classes are at least these: A005811, A136004, A033264, A037800, A069010, A087116, A090079 and many others like A105500, A106826, A166242, A246960, A277561, A037834, A225081 although these have not been fully checked yet.

Programs

  • Mathematica
    f[n_, i_, x_] := Which[n == 0, x, EvenQ@ n, f[n/2, i + 1, x], True, f[(n - 1)/2, i, x Prime@ i]]; g[n_] := If[n == 1, 1, Times @@ MapIndexed[ Prime[First@ #2]^#1 &, Sort[FactorInteger[n][[All, -1]], Greater]]];
    Table[g@ f[BitXor[n, Floor[n/2]], 1, 1], {n, 0, 93}] (* Michael De Vlieger, May 09 2017 *)
  • Python
    from sympy import prime, factorint
    import math
    def A(n): return n - 2**int(math.floor(math.log(n, 2)))
    def b(n): return n + 1 if n<2 else prime(1 + (len(bin(n)[2:]) - bin(n)[2:].count("1"))) * b(A(n))
    def a005940(n): return b(n - 1)
    def P(n):
        f = factorint(n)
        return sorted([f[i] for i in f])
    def a046523(n):
        x=1
        while True:
            if P(n) == P(x): return x
            else: x+=1
    def a003188(n): return n^int(n/2)
    def a243353(n): return a005940(1 + a003188(n))
    def a(n): return a046523(a243353(n)) # Indranil Ghosh, May 07 2017
  • Scheme
    (define (A278219 n) (A046523 (A243353 n)))
    

Formula

a(n) = A046523(A243353(n)).
a(n) = A278222(A003188(n)).
a(n) = A278220(1+A075157(n)).

A014082 Number of occurrences of '111' in binary expansion of n.

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 3, 4, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 2, 3, 0, 0, 0, 0, 0, 0, 0, 1, 0
Offset: 0

Views

Author

Keywords

Comments

a(n) = A213629(n,7) for n > 6. - Reinhard Zumkeller, Jun 17 2012

Crossrefs

Programs

  • Haskell
    import Data.List (tails, isPrefixOf)
    a014082 = sum . map (fromEnum . ([1,1,1] `isPrefixOf`)) .
                        tails . a030308_row
    -- Reinhard Zumkeller, Jun 17 2012
    
  • Maple
    See A014081.
    f:= proc(n) option remember;
      if n::even then procname(n/2)
      elif n mod 8 = 7 then 1 + procname((n-1)/2)
      else procname((n-1)/2)
    fi
    end proc:
    f(0):= 0:
    map(f, [$0..1000]); # Robert Israel, Sep 11 2015
  • Mathematica
    f[n_] := Count[ Partition[ IntegerDigits[n, 2], 3, 1], {1, 1, 1}]; Table[f@n, {n, 0, 104}] (* Robert G. Wilson v, Apr 02 2009 *)
    a[0] = a[1] = 0; a[n_] := a[n] = If[EvenQ[n], a[n/2], a[(n - 1)/2] + Boole[Mod[(n - 1)/2, 4] == 3]]; Table[a[n], {n, 0, 104}] (* Jean-François Alcover, Oct 22 2012, after Ralf Stephan *)
    Table[SequenceCount[IntegerDigits[n,2],{1,1,1},Overlaps->True],{n,0,110}] (* Harvey P. Dale, Mar 05 2023 *)
  • PARI
    a(n) = hammingweight(bitand(n, bitand(n>>1, n>>2))); \\ Gheorghe Coserea, Aug 30 2015

Formula

a(2n) = a(n), a(2n+1) = a(n) + [n congruent to 3 mod 4]. - Ralf Stephan, Aug 21 2003
G.f.: 1/(1-x) * Sum_{k>=0} t^7(1-t)/(1-t^8), where t=x^2^k. - Ralf Stephan, Sep 08 2003

A087116 Number of maximal groups of consecutive zeros in binary representation of n.

Original entry on oeis.org

1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 2, 1, 2, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 3, 2, 2, 2, 2, 1, 2, 2, 3, 2, 3, 3, 3, 2, 2, 2, 3, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2
Offset: 0

Views

Author

Reinhard Zumkeller, Aug 14 2003

Keywords

Comments

The following four statements are equivalent: a(n) = 0; n = 2^k - 1 for some k; A087117(n) = 0; A023416(n) = 0.

Examples

			G.f. = 1 + x^2 + x^4 + x^5 + x^6 + x^8 + x^9 + 2*x^10 + x^11 + x^12 + x^13 + x^14 + ...
		

Crossrefs

Essentially the same as A033264.

Programs

  • Haskell
    a087116 0 = 1
    a087116 n = f 0 n where
       f y 0 = y
       f y x = if r == 0 then g x' else f y x'
               where (x', r) = divMod x 2
                     g z = if r == 0 then g z' else f (y + 1) z'
                           where (z', r) = divMod z 2
    -- Reinhard Zumkeller, Mar 31 2015
    
  • Mathematica
    a[n_] := SequenceCount[IntegerDigits[n, 2], {Longest[0..]}];
    Table[a[n], {n, 0, 101}] (* Jean-François Alcover, Oct 18 2021 *)
  • PARI
    a(n) = if (n == 0, 1, hammingweight(bitxor(n, n>>1)) >> 1);
    vector(102, i, a(i-1))  \\ Gheorghe Coserea, Sep 17 2015
    
  • Python
    def A087116(n):
        return sum(1 for d in bin(n)[2:].split('1') if len(d)) # Chai Wah Wu, Nov 04 2016

Formula

a(n) = A033264(n) for n > 0 since strings of 0's alternate with strings of 1's. - Jonathan Sondow, Jan 17 2016
a(n) = a(2*n + 1) = a(4*n + 2) - 1, if n > 0. - Michael Somos, Nov 04 2016
a(n) = A069010(A003817(n)-n) for n > 0. - Chai Wah Wu, Nov 04 2016

A173318 Partial sums of A005811.

Original entry on oeis.org

0, 1, 3, 4, 6, 9, 11, 12, 14, 17, 21, 24, 26, 29, 31, 32, 34, 37, 41, 44, 48, 53, 57, 60, 62, 65, 69, 72, 74, 77, 79, 80, 82, 85, 89, 92, 96, 101, 105, 108, 112, 117, 123, 128, 132, 137, 141, 144, 146, 149, 153, 156, 160, 165, 169, 172, 174, 177, 181, 184, 186, 189
Offset: 0

Views

Author

Jonathan Vos Post, Feb 16 2010

Keywords

Comments

Partial sums of number of runs in binary expansion of n (n>0). Partial sums of number of 1's in Gray code for n. The subsequence of squares in this partial sum begins 0, 1, 4, 9, 144, 169, 256, 289, 324 (since we also have 32 and 128 I wonder about why so many powers). The subsequence of primes in this partial sum begins: 3, 11, 17, 29, 31, 37, 41, 53, 79, 89, 101, 137, 149, 181, 191, 197, 229, 271.
Note: A227744 now gives the squares, which occur at positions given by A227743. - Antti Karttunen, Jul 27 2013

Examples

			1 has 1 run in its binary representation "1".
2 has 2 runs in its binary representation "10".
3 has 1 run in its binary representation "11".
4 has 2 runs in its binary representation "100".
5 has 3 runs in its binary representation "101".
Thus a(1) = 1, a(2) = 1+2 = 3, a(3) = 1+2+1 = 4, a(4) = 1+2+1+2 = 6, a(5) = 1+2+1+2+3 = 9.
		

Crossrefs

Cf. also A227737, A227741, A227742.
Cf. A227744 (squares occurring), A227743 (indices of squares).

Programs

  • Mathematica
    Accumulate[Join[{0},Table[Length[Split[IntegerDigits[n,2]]],{n,110}]]] (* Harvey P. Dale, Jul 29 2013 *)
  • PARI
    a(n) = my(v=binary(n+1),d=0,e=4); for(i=1,#v, if(v[i], v[i]=#v-i+d;d+=e;e=0, e=4)); fromdigits(v,2)>>1; \\ Kevin Ryde, Aug 27 2021

Formula

a(n) = sum(i=0..n) A005811(i) = sum(i=0..n) (A037834(i)+1) = sum(i=0..n) (A069010(i) + A033264(i)).
a(A000225(n)) = A001787(n) = A000788(A000225(n)). - Antti Karttunen, Jul 27 2013 & Aug 09 2013
a(2n) = 2*a(n) + n - 2*(ceiling(A005811(n)/2) - (n mod 2)), a(2n+1) = 2*a(n) + n + 1. - Ralf Stephan, Aug 11 2013
Showing 1-10 of 19 results. Next