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 24 results. Next

A000120 1's-counting sequence: number of 1's in binary expansion of n (or the binary weight of n).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

The binary weight of n is also called Hamming weight of n. [The term "Hamming weight" was named after the American mathematician Richard Wesley Hamming (1915-1998). - Amiram Eldar, Jun 16 2021]
a(n) is also the largest integer such that 2^a(n) divides binomial(2n, n) = A000984(n). - Benoit Cloitre, Mar 27 2002
To construct the sequence, start with 0 and use the rule: If k >= 0 and a(0), a(1), ..., a(2^k-1) are the first 2^k terms, then the next 2^k terms are a(0) + 1, a(1) + 1, ..., a(2^k-1) + 1. - Benoit Cloitre, Jan 30 2003
An example of a fractal sequence. That is, if you omit every other number in the sequence, you get the original sequence. And of course this can be repeated. So if you form the sequence a(0 * 2^n), a(1 * 2^n), a(2 * 2^n), a(3 * 2^n), ... (for any integer n > 0), you get the original sequence. - Christopher.Hills(AT)sepura.co.uk, May 14 2003
The n-th row of Pascal's triangle has 2^k distinct odd binomial coefficients where k = a(n) - 1. - Lekraj Beedassy, May 15 2003
Fixed point of the morphism 0 -> 01, 1 -> 12, 2 -> 23, 3 -> 34, 4 -> 45, etc., starting from a(0) = 0. - Robert G. Wilson v, Jan 24 2006
a(n) is the number of times n appears among the mystery calculator sequences: A005408, A042964, A047566, A115419, A115420, A115421. - Jeremy Gardiner, Jan 25 2006
a(n) is the number of solutions of the Diophantine equation 2^m*k + 2^(m-1) + i = n, where m >= 1, k >= 0, 0 <= i < 2^(m-1); a(5) = 2 because only (m, k, i) = (1, 2, 0) [2^1*2 + 2^0 + 0 = 5] and (m, k, i) = (3, 0, 1) [2^3*0 + 2^2 + 1 = 5] are solutions. - Hieronymus Fischer, Jan 31 2006
The first appearance of k, k >= 0, is at a(2^k-1). - Robert G. Wilson v, Jul 27 2006
Sequence is given by T^(infinity)(0) where T is the operator transforming any word w = w(1)w(2)...w(m) into T(w) = w(1)(w(1)+1)w(2)(w(2)+1)...w(m)(w(m)+1). I.e., T(0) = 01, T(01) = 0112, T(0112) = 01121223. - Benoit Cloitre, Mar 04 2009
For n >= 2, the minimal k for which a(k(2^n-1)) is not multiple of n is 2^n + 3. - Vladimir Shevelev, Jun 05 2009
Triangle inequality: a(k+m) <= a(k) + a(m). Equality holds if and only if C(k+m, m) is odd. - Vladimir Shevelev, Jul 19 2009
a(k*m) <= a(k) * a(m). - Robert Israel, Sep 03 2023
The number of occurrences of value k in the first 2^n terms of the sequence is equal to binomial(n, k), and also equal to the sum of the first n - k + 1 terms of column k in the array A071919. Example with k = 2, n = 7: there are 21 = binomial(7,2) = 1 + 2 + 3 + 4 + 5 + 6 2's in a(0) to a(2^7-1). - Brent Spillner (spillner(AT)acm.org), Sep 01 2010, simplified by R. J. Mathar, Jan 13 2017
Let m be the number of parts in the listing of the compositions of n as lists of parts in lexicographic order, a(k) = n - length(composition(k)) for all k < 2^n and all n (see example); A007895 gives the equivalent for compositions into odd parts. - Joerg Arndt, Nov 09 2012
From Daniel Forgues, Mar 13 2015: (Start)
Just tally up row k (binary weight equal k) from 0 to 2^n - 1 to get the binomial coefficient C(n,k). (See A007318.)
0 1 3 7 15
0: O | . | . . | . . . . | . . . . . . . . |
1: | O | O . | O . . . | O . . . . . . . |
2: | | O | O O . | O O . O . . . |
3: | | | O | O O O . |
4: | | | | O |
Due to its fractal nature, the sequence is quite interesting to listen to.
(End)
The binary weight of n is a particular case of the digit sum (base b) of n. - Daniel Forgues, Mar 13 2015
The mean of the first n terms is 1 less than the mean of [a(n+1),...,a(2n)], which is also the mean of [a(n+2),...,a(2n+1)]. - Christian Perfect, Apr 02 2015
a(n) is also the largest part of 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 20 2017
a(n) is also known as the population count of the binary representation of n. - Chai Wah Wu, May 19 2020

Examples

			Using the formula a(n) = a(floor(n / floor_pow4(n))) + a(n mod floor_pow4(n)):
  a(4) = a(1) + a(0) = 1,
  a(8) = a(2) + a(0) = 1,
  a(13) = a(3) + a(1) = 2 + 1 = 3,
  a(23) = a(1) + a(7) = 1 + a(1) + a(3) = 1 + 1 + 2 = 4.
_Gary W. Adamson_ points out (Jun 03 2009) that this can be written as a triangle:
  0,
  1,
  1,2,
  1,2,2,3,
  1,2,2,3,2,3,3,4,
  1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
  1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
  1,2,2,3,2,3,...
where the rows converge to A063787.
From _Joerg Arndt_, Nov 09 2012: (Start)
Connection to the compositions of n as lists of parts (see comment):
[ #]:   a(n)  composition
[ 0]:   [0]   1 1 1 1 1
[ 1]:   [1]   1 1 1 2
[ 2]:   [1]   1 1 2 1
[ 3]:   [2]   1 1 3
[ 4]:   [1]   1 2 1 1
[ 5]:   [2]   1 2 2
[ 6]:   [2]   1 3 1
[ 7]:   [3]   1 4
[ 8]:   [1]   2 1 1 1
[ 9]:   [2]   2 1 2
[10]:   [2]   2 2 1
[11]:   [3]   2 3
[12]:   [2]   3 1 1
[13]:   [3]   3 2
[14]:   [3]   4 1
[15]:   [4]   5
(End)
		

References

  • Jean-Paul Allouche and Jeffrey Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 119.
  • Donald E. Knuth, The Art of Computer Programming, vol. 4A, Combinatorial Algorithms, Section 7.1.3, Problem 41, p. 589. - N. J. A. Sloane, Aug 03 2012
  • Manfred R. Schroeder, Fractals, Chaos, Power Laws. W.H. Freeman, 1991, p. 383.
  • N. J. A. Sloane, A Handbook of Integer Sequences, Academic Press, 1973 (includes this sequence).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

The basic sequences concerning the binary expansion of n are this one, A000788, A000069, A001969, A023416, A059015, A007088.
Partial sums see A000788. For run lengths see A131534. See also A001792, A010062.
Number of 0's in n: A023416 and A080791.
a(n) = n - A011371(n).
Sum of digits of n written in bases 2-16: this sequence, A053735, A053737, A053824, A053827, A053828, A053829, A053830, A007953, A053831, A053832, A053833, A053834, A053835, A053836.
This is Guy Steele's sequence GS(3, 4) (see A135416).
Cf. A230952 (boustrophedon transform).
Cf. A070939 (length of binary representation of n).

Programs

  • Fortran
    c See link in A139351
    
  • Haskell
    import Data.Bits (Bits, popCount)
    a000120 :: (Integral t, Bits t) => t -> Int
    a000120 = popCount
    a000120_list = 0 : c [1] where c (x:xs) = x : c (xs ++ [x,x+1])
    -- Reinhard Zumkeller, Aug 26 2013, Feb 19 2012, Jun 16 2011, Mar 07 2011
    
  • Haskell
    a000120 = concat r
        where r = [0] : (map.map) (+1) (scanl1 (++) r)
    -- Luke Palmer, Feb 16 2014
    
  • Magma
    [Multiplicity(Intseq(n, 2), 1): n in [0..104]]; // Marius A. Burtea, Jan 22 2020
    
  • Magma
    [&+Intseq(n, 2):n in [0..104]]; // Marius A. Burtea, Jan 22 2020
  • Maple
    A000120 := proc(n) local w,m,i; w := 0; m := n; while m > 0 do i := m mod 2; w := w+i; m := (m-i)/2; od; w; end: wt := A000120;
    A000120 := n -> add(i, i=convert(n,base,2)): # Peter Luschny, Feb 03 2011
    with(Bits): p:=n->ilog2(n-And(n,n-1)): seq(p(binomial(2*n,n)),n=0..200) # Gary Detlefs, Jan 27 2019
  • Mathematica
    Table[DigitCount[n, 2, 1], {n, 0, 105}]
    Nest[Flatten[# /. # -> {#, # + 1}] &, {0}, 7] (* Robert G. Wilson v, Sep 27 2011 *)
    Table[Plus @@ IntegerDigits[n, 2], {n, 0, 104}]
    Nest[Join[#, # + 1] &, {0}, 7] (* IWABUCHI Yu(u)ki, Jul 19 2012 *)
    Log[2, Nest[Join[#, 2#] &, {1}, 14]] (* gives 2^14 term, Carlos Alves, Mar 30 2014 *)
  • PARI
    {a(n) = if( n<0, 0, 2*n - valuation((2*n)!, 2))};
    
  • PARI
    {a(n) = if( n<0, 0, subst(Pol(binary(n)), x ,1))};
    
  • PARI
    {a(n) = if( n<1, 0, a(n\2) + n%2)}; /* Michael Somos, Mar 06 2004 */
    
  • PARI
    a(n)=my(v=binary(n));sum(i=1,#v,v[i]) \\ Charles R Greathouse IV, Jun 24 2011
    
  • PARI
    a(n)=norml2(binary(n)) \\ better use {A000120=hammingweight}. - M. F. Hasler, Oct 09 2012, edited Feb 27 2020
    
  • PARI
    a(n)=hammingweight(n) \\ Michel Marcus, Oct 19 2013
    (Common Lisp) (defun floor-to-power (n pow) (declare (fixnum pow)) (expt pow (floor (log n pow)))) (defun enabled-bits (n) (if (< n 4) (n-th n (list 0 1 1 2)) (+ (enabled-bits (floor (/ n (floor-to-power n 4)))) (enabled-bits (mod n (floor-to-power n 4)))))) ; Stephen K. Touset (stephen(AT)touset.org), Apr 04 2007
    
  • Python
    def A000120(n): return bin(n).count('1') # Chai Wah Wu, Sep 03 2014
    
  • Python
    import numpy as np
    A000120 = np.array([0], dtype="uint8")
    for bitrange in range(25): A000120 = np.append(A000120, np.add(A000120, 1))
    print([A000120[n] for n in range(0, 105)]) # Karl-Heinz Hofmann, Nov 07 2022
    
  • Python
    def A000120(n): return n.bit_count() # Requires Python 3.10 or higher. - Pontus von Brömssen, Nov 08 2022
    
  • Python
    # Also see links.
    
  • SageMath
    def A000120(n):
        if n <= 1: return Integer(n)
        return A000120(n//2) + n%2
    [A000120(n) for n in range(105)]  # Peter Luschny, Nov 19 2012
    
  • SageMath
    def A000120(n) : return sum(n.digits(2)) # Eric M. Schmidt, Apr 26 2013
    
  • Scala
    (0 to 127).map(Integer.bitCount()) // _Alonso del Arte, Mar 05 2019
    

Formula

a(0) = 0, a(2*n) = a(n), a(2*n+1) = a(n) + 1.
a(0) = 0, a(2^i) = 1; otherwise if n = 2^i + j with 0 < j < 2^i, a(n) = a(j) + 1.
G.f.: Product_{k >= 0} (1 + y*x^(2^k)) = Sum_{n >= 0} y^a(n)*x^n. - N. J. A. Sloane, Jun 04 2009
a(n) = a(n-1) + 1 - A007814(n) = log_2(A001316(n)) = 2n - A005187(n) = A070939(n) - A023416(n). - Henry Bottomley, Apr 04 2001; corrected by Ralf Stephan, Apr 15 2002
a(n) = log_2(A000984(n)/A001790(n)). - Benoit Cloitre, Oct 02 2002
For n > 0, a(n) = n - Sum_{k=1..n} A007814(k). - Benoit Cloitre, Oct 19 2002
a(n) = n - Sum_{k>=1} floor(n/2^k) = n - A011371(n). - Benoit Cloitre, Dec 19 2002
G.f.: (1/(1-x)) * Sum_{k>=0} x^(2^k)/(1+x^(2^k)). - Ralf Stephan, Apr 19 2003
a(0) = 0, a(n) = a(n - 2^floor(log_2(n))) + 1. Examples: a(6) = a(6 - 2^2) + 1 = a(2) + 1 = a(2 - 2^1) + 1 + 1 = a(0) + 2 = 2; a(101) = a(101 - 2^6) + 1 = a(37) + 1 = a(37 - 2^5) + 2 = a(5 - 2^2) + 3 = a(1 - 2^0) + 4 = a(0) + 4 = 4; a(6275) = a(6275 - 2^12) + 1 = a(2179 - 2^11) + 2 = a(131 - 2^7) + 3 = a(3 - 2^1) + 4 = a(1 - 2^0) + 5 = 5; a(4129) = a(4129 - 2^12) + 1 = a(33 - 2^5) + 2 = a(1 - 2^0) + 3 = 3. - Hieronymus Fischer, Jan 22 2006
A fixed point of the mapping 0 -> 01, 1 -> 12, 2 -> 23, 3 -> 34, 4 -> 45, ... With f(i) = floor(n/2^i), a(n) is the number of odd numbers in the sequence f(0), f(1), f(2), f(3), f(4), f(5), ... - Philippe Deléham, Jan 04 2004
When read mod 2 gives the Morse-Thue sequence A010060.
Let floor_pow4(n) denote n rounded down to the next power of four, floor_pow4(n) = 4 ^ floor(log4 n). Then a(0) = 0, a(1) = 1, a(2) = 1, a(3) = 2, a(n) = a(floor(n / floor_pow4(n))) + a(n % floor_pow4(n)). - Stephen K. Touset (stephen(AT)touset.org), Apr 04 2007
a(n) = n - Sum_{k=2..n} Sum_{j|n, j >= 2} (floor(log_2(j)) - floor(log_2(j-1))). - Hieronymus Fischer, Jun 18 2007
a(n) = A138530(n, 2) for n > 1. - Reinhard Zumkeller, Mar 26 2008
a(A077436(n)) = A159918(A077436(n)); a(A000290(n)) = A159918(n). - Reinhard Zumkeller, Apr 25 2009
a(n) = A063787(n) - A007814(n). - Gary W. Adamson, Jun 04 2009
a(n) = A007814(C(2n, n)) = 1 + A007814(C(2n-1, n)). - Vladimir Shevelev, Jul 20 2009
For odd m >= 1, a((4^m-1)/3) = a((2^m+1)/3) + (m-1)/2 (mod 2). - Vladimir Shevelev, Sep 03 2010
a(n) - a(n-1) = { 1 - a(n-1) if and only if A007814(n) = a(n-1), 1 if and only if A007814(n) = 0, -1 for all other A007814(n) }. - Brent Spillner (spillner(AT)acm.org), Sep 01 2010
a(A001317(n)) = 2^a(n). - Vladimir Shevelev, Oct 25 2010
a(n) = A139351(n) + A139352(n) = Sum_k {A030308(n, k)}. - Philippe Deléham, Oct 14 2011
From Hieronymus Fischer, Jun 10 2012: (Start)
a(n) = Sum_{j = 1..m+1} (floor(n/2^j + 1/2) - floor(n/2^j)), where m = floor(log_2(n)).
General formulas for the number of digits >= d in the base p representation of n, where 1 <= d < p: a(n) = Sum_{j = 1..m+1} (floor(n/p^j + (p-d)/p) - floor(n/p^j)), where m=floor(log_p(n)); g.f.: g(x) = (1/(1-x))*Sum_{j>=0} (x^(d*p^j) - x^(p*p^j))/(1-x^(p*p^j)). (End)
a(n) = A213629(n, 1) for n > 0. - Reinhard Zumkeller, Jul 04 2012
a(n) = A240857(n,n). - Reinhard Zumkeller, Apr 14 2014
a(n) = log_2(C(2*n,n) - (C(2*n,n) AND C(2*n,n)-1)). - Gary Detlefs, Jul 10 2014
Sum_{n >= 1} a(n)/2n(2n+1) = (gamma + log(4/Pi))/2 = A344716, where gamma is Euler's constant A001620; see Sondow 2005, 2010 and Allouche, Shallit, Sondow 2007. - Jonathan Sondow, Mar 21 2015
For any integer base b >= 2, the sum of digits s_b(n) of expansion base b of n is the solution of this recurrence relation: s_b(n) = 0 if n = 0 and s_b(n) = s_b(floor(n/b)) + (n mod b). Thus, a(n) satisfies: a(n) = 0 if n = 0 and a(n) = a(floor(n/2)) + (n mod 2). This easily yields a(n) = Sum_{i = 0..floor(log_2(n))} (floor(n/2^i) mod 2). From that one can compute a(n) = n - Sum_{i = 1..floor(log_2(n))} floor(n/2^i). - Marek A. Suchenek, Mar 31 2016
Sum_{k>=1} a(k)/2^k = 2 * Sum_{k >= 0} 1/(2^(2^k)+1) = 2 * A051158. - Amiram Eldar, May 15 2020
Sum_{k>=1} a(k)/(k*(k+1)) = A016627 = log(4). - Bernard Schott, Sep 16 2020
a(m*(2^n-1)) >= n. Equality holds when 2^n-1 >= A000265(m), but also in some other cases, e.g., a(11*(2^2-1)) = 2 and a(19*(2^3-1)) = 3. - Pontus von Brömssen, Dec 13 2020
G.f.: A(x) satisfies A(x) = (1+x)*A(x^2) + x/(1-x^2). - Akshat Kumar, Nov 04 2023

A130196 Period 3: repeat [1, 2, 2].

Original entry on oeis.org

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

Views

Author

Paul Curtz, Aug 05 2007

Keywords

Comments

From Reinhard Zumkeller, Nov 12 2009: (Start)
Denominator of x(n) = x(n-1) + x(n-2), x(0)=0, x(1)=1/2; numerator = A167808;
a(n) = A131534(n) + A022003(n) = A080425(n) - A131534(n) + 2 = A153727(n)/A131534(n). (End)
Continued fraction expansion of (5+sqrt(85))/10. - Klaus Brockhaus, May 07 2010

Crossrefs

Cf. A177347 (decimal expansion of (5+sqrt(85))/10).

Programs

Formula

a(n+3) = a(n) with a(0)=1, a(1)=a(2)=2.
G.f.: (1+2*x+2*x^2)/(1-x)*(x^2+x+1). - R. J. Mathar, Nov 14 2007
a(n) = (5 - 2*cos(2*Pi*n/3))/3. - Jaume Oliver Lafont, Nov 23 2008
a(n) = 2 - 0^(n mod 3). - Reinhard Zumkeller, Nov 12 2009
a(n) = A011655(n) + 1 = (n^2 mod 3) + 1. - Boris Putievskiy, Feb 03 2013
a(n) = floor((n+1)*5/3) - floor(n*5/3). - Hailey R. Olafson, Jul 23 2014
E.g.f.: (5*exp(x) - 2*exp(-x/2)*cos(sqrt(3)*x/2))/3. - Stefano Spezia, Jun 03 2021

Extensions

More terms from Klaus Brockhaus, May 07 2010

A004772 Numbers that are not congruent to 1 (mod 4).

Original entry on oeis.org

0, 2, 3, 4, 6, 7, 8, 10, 11, 12, 14, 15, 16, 18, 19, 20, 22, 23, 24, 26, 27, 28, 30, 31, 32, 34, 35, 36, 38, 39, 40, 42, 43, 44, 46, 47, 48, 50, 51, 52, 54, 55, 56, 58, 59, 60, 62, 63, 64, 66, 67, 68, 70, 71, 72, 74, 75, 76, 78, 79, 80, 82, 83, 84, 86, 87, 88, 90
Offset: 1

Views

Author

Keywords

Comments

Numbers whose binary expansion does not end in 01.
Equals partial sums of 0 together with 2, 1, 1, 2, 1, 1, ... (repeated, that is A131534 without the first term). - Bruno Berselli, Dec 06 2016
It seems that the numbers m = 3*(a(n)+1)= 1, 7, 10, 13, 19, 22, 25, 31, 34 ... are exactly the indices of Fibonacci numbers F_m that start 5 consecutive pairwise coprime F_m, F_{m+1}, ..., F_{m+4}. E.g. for m=13 the numbers {233,377,610,987,1597} are coprime. - R. J. Mathar, Mar 04 2025

Crossrefs

Cf. A016813 (complement), A042965, A131534.

Programs

Formula

G.f.: x^2*(2 + x + x^2)/((1 + x + x^2)*(x - 1)^2). - R. J. Mathar, Oct 08 2011
a(n) = floor((4*n-2)/3). - Gary Detlefs, Jan 02 2012
a(n) = n + ceiling((n-1)/3) - 1. - Arkadiusz Wesolowski, Sep 18 2012
From Ant King, Oct 19 2012: (Start)
a(n) = 4 + a(n-3).
a(n) = (12*n -9 - 3*cos(2*(n-1)*Pi/3) + sqrt(3)*sin(2*(n-1)*Pi/3))/9. (End)
a(n) = ceiling(4*(n-1)/3). - Jean-François Alcover, Mar 07 2014
Sum_{n>=2} (-1)^n/a(n) = log(sqrt(2)+2)/(2*sqrt(2)) + (2-sqrt(2))*log(2)/8 - (sqrt(2)-1)*Pi/8. - Amiram Eldar, Dec 05 2021
a(n) = A042965(n+1)-1. - R. J. Mathar, Mar 04 2025

Extensions

Corrected by Michael Somos, Jun 08 2000

A153727 Period 3: repeat [1, 4, 2] ; Trajectory of 3x+1 sequence starting at 1.

Original entry on oeis.org

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

Views

Author

Philippe Deléham, Dec 30 2008

Keywords

Comments

From Klaus Brockhaus, May 23 2010: (Start)
Continued fraction expansion of (7+sqrt(229))/18.
Decimal expansion of 142/999. (End)
a(A008585(n)) = 1; a(A016777(n)) = 4; a(A016789(n)) = 2. - Reinhard Zumkeller, Oct 08 2011

References

  • C. A. Pickover, The Math Book, 2009; Collatz Conjecture, pp 374-375.

Crossrefs

Row 1 of A347270.
Cf. A178236 (decimal expansion of (7+sqrt(229))/18). Appears in A179133 (n>=1).

Programs

Formula

a(3n)=1, a(3n+1)=4, a(3n+2)=2.
G.f.: (1+4*x+2*x^2)/(1-x^3).
a(n) = 4^n mod 7. - Zerinvary Lajos, Nov 25 2009
a(n) = A130196(n) * A131534(n). - Reinhard Zumkeller, Nov 12 2009
a(n) = 2^(-n mod 3) = 2^A080425(n). - Wesley Ivan Hurt, Jun 20 2014
a(n) = sqrt(4^(5*n) mod 21). - Gary Detlefs, Jul 07 2014
From Wesley Ivan Hurt, Jun 30 2016: (Start)
a(n) = a(n-3) for n>2.
a(n) = (7 - 4*cos(2*n*Pi/3) + 2*sqrt(3)*sin(2*n*Pi/3))/3. (End)

A080425 Period 3: repeat [0, 2, 1].

Original entry on oeis.org

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

Views

Author

Paul Barry, Feb 20 2003

Keywords

Comments

Previous name was: Jacobsthal selector sequence.
The Jacobsthal sequence A001045 can be defined by A001045(n) = Sum_{k=0..floor(n,3)} C(n, a(n-1)+3*k).
The floor of the area under the polygon connecting the lattice points: (n, a(n)) from 0..n is A001477(n), the nonnegative integers. - Wesley Ivan Hurt, Jun 16 2014

Crossrefs

Programs

Formula

a(n) = ceiling(((n mod 3) + 1)/2) + (-1)^((n mod 3) + 1).
G.f.: x*(x+2)/(1-x^3). - Paul Barry, May 25 2003
a(n) = (3 - (n mod 3)) mod 3. - Reinhard Zumkeller, Jul 30 2005
a(n) = 2 * A001045(L(n/3)), where L(j/p) is the Legendre symbol of j and p.
a(n) = (-n) mod 3; also a(n) = 3*ceiling(n/3)-n. - Hieronymus Fischer, May 29 2007
a(n) = A130196(n) + A131534(n) - 2. - Reinhard Zumkeller, Nov 12 2009
a(n) = (2n) mod 3. - Wesley Ivan Hurt, Jun 23 2013
From Wesley Ivan Hurt, Jul 02 2016: (Start)
a(n) = a(n-3) for n>2.
a(n) = 2*sin(n*Pi/3)*(3*sin(n*Pi/3) + sqrt(3)*cos(n*Pi/3))/3. (End)

Extensions

More terms from Reinhard Zumkeller, Jul 30 2005
New name from Joerg Arndt, Apr 21 2014

A022003 Decimal expansion of 1/999.

Original entry on oeis.org

0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1
Offset: 0

Views

Author

Keywords

Comments

Expansion in any base b of 1/(b^3-1). E.g., 1/7 in base 2, 1/26 in base 3, 1/63 in base 4, etc. - Franklin T. Adams-Watters, Nov 07 2006
a(n) = A130196(n) - A131534(n). - Reinhard Zumkeller, Nov 12 2009

Examples

			0.001001001001001001001...
		

Crossrefs

Essentially the same as A079978.
Cf. A068601.
Partial sums are given by A002264(n+1).

Programs

  • Mathematica
    Join[{0,0},RealDigits[1/999,10,120][[1]]] (* or *) PadRight[{},120,{0,0,1}] (* Harvey P. Dale, May 24 2012 *)
  • PARI
    a(n)=n%3==2 \\ Jaume Oliver Lafont, Mar 24 2009

Formula

From Mario Catalani (mario.catalani(AT)unito.it), Jan 07 2003: (Start)
G.f.: x^2/(1-x^3).
a(n) = -(1/2)*((-1)^floor((2n-1)/3) + (-1)^floor((2n+1)/3)). (End)
From Hieronymus Fischer, May 29 2007: (Start)
a(n) = ((n+2) mod 3) mod 2.
a(n) = (1/2)*(1 - (-1)^(n + floor((n+2)/3))). (End)
a(n) = (1 + (-1)^Fibonacci(n+1))/2. - Hieronymus Fischer, Jun 14 2007
a(n) = (n^5 - n^2) mod 3. - Gary Detlefs, Mar 20 2010
a(n) = ((-1)^(a(n-1) + a(n-2)) + 1)/2 starting from n=3. - Adriano Caroli, Nov 21 2010
a(n) = 1 - Fibonacci(n+1) mod 2. - Gary Detlefs, Dec 26 2010
a(n) = floor((n+1)/3) - floor(n/3). - Tani Akinari, Oct 22 2012

A131713 Period 3: repeat [1, -2, 1].

Original entry on oeis.org

1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1, 1, -2, 1
Offset: 0

Views

Author

Paul Curtz, Sep 14 2007

Keywords

Comments

Second differences of A131534. Binomial transform of 1, -3, 6, -9, 9, 0, ..., A057083 signed.
Nonsimple continued fraction expansion of sqrt(2)-1 = 0.414213562... - R. J. Mathar, Mar 08 2012

Crossrefs

Programs

  • Magma
    &cat [[1, -2, 1]^^30]; // Wesley Ivan Hurt, Jul 01 2016
  • Maple
    seq(op([1, -2, 1]), n=0..50); # Wesley Ivan Hurt, Jul 01 2016
  • Mathematica
    f[n_] := If[ Mod[n, 3] == 1, -2, 1]; Array[f, 105, 0]
    CoefficientList[Series[(1 - x)/(1 + x + x^2), {x, 0, 104}], x]
    PadRight[{}, 120, {1,-2,1}] (* Harvey P. Dale, Jan 25 2014 *)
  • PARI
    a(n)=[1,-2,1][1+n%3] \\ Jaume Oliver Lafont, Mar 24 2009
    
  • PARI
    a(n)=1-3*(n%3==1) \\ Jaume Oliver Lafont, Mar 24 2009
    

Formula

a(n) = b(2*n + 1) where b(n) is multiplicative with b(2^n) = 0^n, b(3^n) = 3 * 0^n - 2, b(p^n) = 1 if p > 3. - Michael Somos, Jan 02 2011
G.f.: (1-x)/(x^2+x+1). - R. J. Mathar, Nov 14 2007
a(n) = 2*cos((2n+1)*Pi/3). - Jaume Oliver Lafont, Nov 23 2008
a(n) = A117188(2*n). - R. J. Mathar, Jun 13 2011
a(n) + a(n-1) + a(n-2) = 0 for n>1, a(n) = a(n-3) for n>2. - Wesley Ivan Hurt, Jul 01 2016
a(n) = (1/4^n) * Sum_{k = 0..n} binomial(2*n+1,2*k)*(-3)^k. - Peter Bala, Feb 06 2019
E.g.f.: 2*exp(-x/2)*cos(sqrt(3)*x/2 + Pi/3). - Fabian Pereyra, Oct 17 2024

Extensions

Corrected and extended by Michael Somos, Jan 02 2011

A167808 Numerator of x(n), where x(n) = x(n-1) + x(n-2) with x(0)=0, x(1)=1/2.

Original entry on oeis.org

0, 1, 1, 1, 3, 5, 4, 13, 21, 17, 55, 89, 72, 233, 377, 305, 987, 1597, 1292, 4181, 6765, 5473, 17711, 28657, 23184, 75025, 121393, 98209, 317811, 514229, 416020, 1346269, 2178309, 1762289, 5702887, 9227465, 7465176, 24157817, 39088169, 31622993
Offset: 0

Views

Author

Reinhard Zumkeller, Nov 12 2009

Keywords

Comments

Define a sequence c(n) by c(0)=0, c(1)=1; thereafter c(n) = (c(n-2)*c(n-1)-1)/(c(n-2)+c(n-1)+2). Then it appears that (apart from signs), a(n) is the denominator of c(n). - Jonas Holmvall, Jun 21 2023

Crossrefs

Cf. A000045, A130196 (denominator).
The a(2*n) appear in A179135. - Johannes W. Meijer, Jul 01 2010

Programs

  • GAP
    a:=[0,1,1,1,3,5];; for n in [7..40] do a[n]:=4*a[n-3]+a[n-6]; od; a; # Muniru A Asiru, Oct 16 2018
  • Maple
    nmax:=39; x(0):=0: x(1):=1/2:for n from 2 to nmax do x(n):=x(n-1)+x(n-2) od: for n from 0 to nmax do a(n):= numer(x(n)) od: seq(a(n),n=0..nmax); # Johannes W. Meijer, Jul 01 2010
    with(combinat):f:=n->fibonacci(n):L:=n->f(n)+2*f(n-1):seq(numer(f(n)/L(n)), n=0..39); # Gary Detlefs, Dec 11 2010
  • Mathematica
    f[n_]:=Numerator[Fibonacci[n]/Fibonacci[n+3]];Array[f,100,0] (* Vladimir Joseph Stephan Orlovsky, Feb 17 2011*)
    Numerator[LinearRecurrence[{1,1},{0,1/2},40]] (* Harvey P. Dale, Aug 08 2014 *)
    CoefficientList[Series[-x (1 + x + x^2 - x^3 + x^4)/((x^2 + x - 1) (x^4 - x^3 + 2 x^2 + x + 1)), {x, 0, 40}], x] (* Vincenzo Librandi, Aug 08 2014 *)
    LinearRecurrence[{0, 0, 4, 0, 0, 1},{0, 1, 1, 1, 3, 5},40] (* Ray Chandler, Aug 03 2015 *)
    a[n_]:=If[Mod[n,3]==0, Fibonacci[n]/2, Fibonacci[n]]; Array[a, 40, 0] (* Stefano Spezia, Oct 16 2018 *)

Formula

a(n) = (a(n-1)*A131534(n) + a(n-2)*A131534(n+2))/A131534(n+1) for n > 1.
a(3*n) = A001076(n) = (a(3*n-1) + a(3*n-2))/2;
a(3*n+1) = A033887(n) = 2*a(3*n-1) + a(3*n-2);
a(3*n+2) = A015448(n+1) = a(3*n-1) + 2*a(3*n-2).
From Johannes W. Meijer, Jul 01 2010: (Start)
a(2*n) = A001906(n)/A131534(n+1) for n >= 0 and a(2*n+1) = A179131(n)/5 for n >= 1.
a(6*n+2) - 2*a(6*n) = A134493(n);
2*a(6*n+1) - a(6*n+3) = A023039(n);
2*a(6*n+4) - a(6*n+2) = A134497(n);
a(6*n+5) - 2*a(6*n+3) = A103134(n);
2*a(6*n+4) - a(6*n+6) = A075796(n).
(End)
From Gary Detlefs, Dec 11 2010: (Start)
a(n) = numerator(A000045(n)/A000032(n)).
If n mod 3 = 0 then a(n) = Fibonacci(n)/2, else a(n)= Fibonacci(n). (End)
G.f.: -x*(1 + x + x^2 - x^3 + x^4) / ( (x^2 + x - 1)*(x^4 - x^3 + 2*x^2 + x + 1) ). - R. J. Mathar, Mar 08 2011
a(n) = 4*a(n-3) + a(n-6). - Muniru A Asiru, Oct 16 2018

Extensions

Typo in title corrected by Johannes W. Meijer, Jun 26 2010

A143978 a(n) = floor(2*n*(n+1)/3).

Original entry on oeis.org

1, 4, 8, 13, 20, 28, 37, 48, 60, 73, 88, 104, 121, 140, 160, 181, 204, 228, 253, 280, 308, 337, 368, 400, 433, 468, 504, 541, 580, 620, 661, 704, 748, 793, 840, 888, 937, 988, 1040, 1093, 1148, 1204, 1261, 1320, 1380, 1441, 1504, 1568, 1633, 1700, 1768, 1837
Offset: 1

Views

Author

Clark Kimberling, Sep 06 2008

Keywords

Comments

Second diagonal of array A143979, which counts certain unit squares in a lattice. First diagonal: A030511.
Convolution of A042965 with A000012, convolution of A131534 with A000027, and convolution of A106510 with A000217. - L. Edson Jeffery, Jan 24 2015
From Miquel A. Fiol, Aug 31 2024: (Start)
a(n+1) is the maximum number N of vertices of a circulant digraph with steps +-s1, s2, and diameter n.
Depending on the value of n, the following table shows the values of N, s1, and s2:
n | 3*r | 3*r-1 | 3*r-2 |
N | 6*r^2+6*r+1 | 6*r^2+2*r | 6*r^2-2*r |
s1 | 1 | r | r |
s2 | 6*r+3 | 3*r+1 | 3*r-1 |
(End)

Crossrefs

Cf. A000217, A030511, A042965 (first differences), A106510, A131534, A143979.

Programs

  • Maple
    A143978:= n-> (6*n*(n+1) -1 + `mod`(n+2,3) - `mod`(n+1,3))/9;
    seq(A143978(n), n=1..60); # G. C. Greubel, May 27 2020
  • Mathematica
    Table[(6*n^2 +6*n -1  + Mod[n+2, 3] - Mod[n+1, 3])/9, {n, 60}] (* G. C. Greubel, May 27 2020 *)
    Table[Floor[2n (n+1)/3],{n,60}] (* or *) LinearRecurrence[{2,-1,1,-2,1},{1,4,8,13,20},60] (* Harvey P. Dale, Aug 12 2025 *)

Formula

From R. J. Mathar, Oct 05 2009: (Start)
G.f.: x*(1 + x)^2/((1 + x + x^2)*(1-x)^3).
a(n) = 2*a(n-1) - a(n-2) + a(n-3) - 2*a(n-4) + a(n-5). (End)
a(n) = Sum_{k=1..(n+1)} A042965(k). - Klaus Purath, May 23 2020
From G. C. Greubel, May 27 2020: (Start)
a(n) = (ChebyshevU(n, -1/2) - ChebyshevU(n-1, -1/2) + (6*n^2 + 6*n -1))/9.
a(n) = (JacobiSymbol(n+1, 3) - JacobiSymbol(n, 3) + (6*n^2 + 6*n -1))/9.
a(n) = (A102283(n+1) - A102283(n) + A103115(n+1))/9
a(n) = (A131713(n) + A103115(n+1))/9. (End)
Sum_{n>=1} 1/a(n) = 3/2 + (tan(Pi/(2*sqrt(3)))-1)*Pi/(2*sqrt(3)). - Amiram Eldar, Sep 27 2022
E.g.f.: exp(-x/2)*(exp(3*x/2)*(6*x^2 + 12*x - 1) + cos(sqrt(3)*x/2) - sqrt(3)*sin(sqrt(3)*x/2))/9. - Stefano Spezia, Apr 05 2023

A131556 Period 6: repeat [1, -2, 1, -1, 2, -1].

Original entry on oeis.org

1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1, 1, -2, 1, -1, 2, -1
Offset: 0

Views

Author

Paul Curtz, Aug 27 2007

Keywords

Crossrefs

Cf. A131534.

Programs

Formula

G.f.: (x-1)^2/(x+1)/(x^2-x+1). - R. J. Mathar, Nov 14 2007
a(n) = (-1)^n * A131534(n). - R. J. Mathar, Apr 02 2011
a(n) = -cos(Pi*n/3)/3 -sin(Pi*n/3)/sqrt(3) +4*(-1)^n/3. - R. J. Mathar, Oct 08 2011
a(n) + a(n-3) = 0 for n>2. - Wesley Ivan Hurt, Jun 19 2016

Extensions

Edited by N. J. A. Sloane, Sep 15 2007
Showing 1-10 of 24 results. Next