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

A005408 The odd numbers: a(n) = 2*n + 1.

Original entry on oeis.org

1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131
Offset: 0

Views

Author

Keywords

Comments

Leibniz's series: Pi/4 = Sum_{n>=0} (-1)^n/(2n+1) (cf. A072172).
Beginning of the ordering of the natural numbers used in Sharkovski's theorem - see the Cielsielski-Pogoda paper.
The Sharkovski ordering begins with the odd numbers >= 3, then twice these numbers, then 4 times them, then 8 times them, etc., ending with the powers of 2 in decreasing order, ending with 2^0 = 1.
Apart from initial term(s), dimension of the space of weight 2n cusp forms for Gamma_0(6).
Also continued fraction for coth(1) (A073747 is decimal expansion). - Rick L. Shepherd, Aug 07 2002
a(1) = 1; a(n) is the smallest number such that a(n) + a(i) is composite for all i = 1 to n-1. - Amarnath Murthy, Jul 14 2003
Smallest number greater than n, not a multiple of n, but containing it in binary representation. - Reinhard Zumkeller, Oct 06 2003
Numbers n such that phi(2n) = phi(n), where phi is Euler's totient (A000010). - Lekraj Beedassy, Aug 27 2004
Pi*sqrt(2)/4 = Sum_{n>=0} (-1)^floor(n/2)/(2n+1) = 1 + 1/3 - 1/5 - 1/7 + 1/9 + 1/11 ... [since periodic f(x)=x over -Pi < x < Pi = 2(sin(x)/1 - sin(2x)/2 + sin(3x)/3 - ...) using x = Pi/4 (Maor)]. - Gerald McGarvey, Feb 04 2005
For n > 1, numbers having 2 as an anti-divisor. - Alexandre Wajnberg, Oct 02 2005
a(n) = shortest side a of all integer-sided triangles with sides a <= b <= c and inradius n >= 1.
First differences of squares (A000290). - Lekraj Beedassy, Jul 15 2006
The odd numbers are the solution to the simplest recursion arising when assuming that the algorithm "merge sort" could merge in constant unit time, i.e., T(1):= 1, T(n):= T(floor(n/2)) + T(ceiling(n/2)) + 1. - Peter C. Heinig (algorithms(AT)gmx.de), Oct 14 2006
2n-5 counts the permutations in S_n which have zero occurrences of the pattern 312 and one occurrence of the pattern 123. - David Hoek (david.hok(AT)telia.com), Feb 28 2007
For n > 0: number of divisors of (n-1)th power of any squarefree semiprime: a(n) = A000005(A001248(k)^(n-1)); a(n) = A000005(A000302(n-1)) = A000005(A001019(n-1)) = A000005(A009969(n-1)) = A000005(A087752(n-1)). - Reinhard Zumkeller, Mar 04 2007
For n > 2, a(n-1) is the least integer not the sum of < n n-gonal numbers (0 allowed). - Jonathan Sondow, Jul 01 2007
A134451(a(n)) = abs(A134452(a(n))) = 1; union of A134453 and A134454. - Reinhard Zumkeller, Oct 27 2007
Numbers n such that sigma(2n) = 3*sigma(n). - Farideh Firoozbakht, Feb 26 2008
a(n) = A139391(A016825(n)) = A006370(A016825(n)). - Reinhard Zumkeller, Apr 17 2008
Number of divisors of 4^(n-1) for n > 0. - J. Lowell, Aug 30 2008
Equals INVERT transform of A078050 (signed - cf. comments); and row sums of triangle A144106. - Gary W. Adamson, Sep 11 2008
Odd numbers(n) = 2*n+1 = square pyramidal number(3*n+1) / triangular number(3*n+1). - Pierre CAMI, Sep 27 2008
A000035(a(n))=1, A059841(a(n))=0. - Reinhard Zumkeller, Sep 29 2008
Multiplicative closure of A065091. - Reinhard Zumkeller, Oct 14 2008
a(n) is also the maximum number of triangles that n+2 points in the same plane can determine. 3 points determine max 1 triangle; 4 points can give 3 triangles; 5 points can give 5; 6 points can give 7 etc. - Carmine Suriano, Jun 08 2009
Binomial transform of A130706, inverse binomial transform of A001787(without the initial 0). - Philippe Deléham, Sep 17 2009
Also the 3-rough numbers: positive integers that have no prime factors less than 3. - Michael B. Porter, Oct 08 2009
Or n without 2 as prime factor. - Juri-Stepan Gerasimov, Nov 19 2009
Given an L(2,1) labeling l of a graph G, let k be the maximum label assigned by l. The minimum k possible over all L(2,1) labelings of G is denoted by lambda(G). For n > 0, this sequence gives lambda(K_{n+1}) where K_{n+1} is the complete graph on n+1 vertices. - K.V.Iyer, Dec 19 2009
A176271 = odd numbers seen as a triangle read by rows: a(n) = A176271(A002024(n+1), A002260(n+1)). - Reinhard Zumkeller, Apr 13 2010
For n >= 1, a(n-1) = numbers k such that arithmetic mean of the first k positive integers is an integer. A040001(a(n-1)) = 1. See A145051 and A040001. - Jaroslav Krizek, May 28 2010
Union of A179084 and A179085. - Reinhard Zumkeller, Jun 28 2010
For n>0, continued fraction [1,1,n] = (n+1)/a(n); e.g., [1,1,7] = 8/15. - Gary W. Adamson, Jul 15 2010
Numbers that are the sum of two sequential integers. - Dominick Cancilla, Aug 09 2010
Cf. property described by Gary Detlefs in A113801: more generally, these numbers are of the form (2*h*n + (h-4)*(-1)^n - h)/4 (h and n in A000027), therefore ((2*h*n + (h-4)*(-1)^n - h)/4)^2 - 1 == 0 (mod h); in this case, a(n)^2 - 1 == 0 (mod 4). Also a(n)^2 - 1 == 0 (mod 8). - Bruno Berselli, Nov 17 2010
A004767 = a(a(n)). - Reinhard Zumkeller, Jun 27 2011
A001227(a(n)) = A000005(a(n)); A048272(a(n)) < 0. - Reinhard Zumkeller, Jan 21 2012
a(n) is the minimum number of tosses of a fair coin needed so that the probability of more than n heads is at least 1/2. In fact, Sum_{k=n+1..2n+1} Pr(k heads|2n+1 tosses) = 1/2. - Dennis P. Walsh, Apr 04 2012
A007814(a(n)) = 0; A037227(a(n)) = 1. - Reinhard Zumkeller, Jun 30 2012
1/N (i.e., 1/1, 1/2, 1/3, ...) = Sum_{j=1,3,5,...,infinity} k^j, where k is the infinite set of constants 1/exp.ArcSinh(N/2) = convergents to barover(N). The convergent to barover(1) or [1,1,1,...] = 1/phi = 0.6180339..., whereas c.f. barover(2) converges to 0.414213..., and so on. Thus, with k = 1/phi we obtain 1 = k^1 + k^3 + k^5 + ..., and with k = 0.414213... = (sqrt(2) - 1) we get 1/2 = k^1 + k^3 + k^5 + .... Likewise, with the convergent to barover(3) = 0.302775... = k, we get 1/3 = k^1 + k^3 + k^5 + ..., etc. - Gary W. Adamson, Jul 01 2012
Conjecture on primes with one coach (A216371) relating to the odd integers: iff an integer is in A216371 (primes with one coach either of the form 4q-1 or 4q+1, (q > 0)); the top row of its coach is composed of a permutation of the first q odd integers. Example: prime 19 (q = 5), has 5 terms in each row of its coach: 19: [1, 9, 5, 7, 3] ... [1, 1, 1, 2, 4]. This is interpreted: (19 - 1) = (2^1 * 9), (19 - 9) = (2^1 * 5), (19 - 5) = (2^1 - 7), (19 - 7) = (2^2 * 3), (19 - 3) = (2^4 * 1). - Gary W. Adamson, Sep 09 2012
A005408 is the numerator 2n-1 of the term (1/m^2 - 1/n^2) = (2n-1)/(mn)^2, n = m+1, m > 0 in the Rydberg formula, while A035287 is the denominator (mn)^2. So the quotient a(A005408)/a(A035287) simulates the Hydrogen spectral series of all hydrogen-like elements. - Freimut Marschner, Aug 10 2013
This sequence has unique factorization. The primitive elements are the odd primes (A065091). (Each term of the sequence can be expressed as a product of terms of the sequence. Primitive elements have only the trivial factorization. If the products of terms of the sequence are always in the sequence, and there is a unique factorization of each element into primitive elements, we say that the sequence has unique factorization. So, e.g., the composite numbers do not have unique factorization, because for example 36 = 4*9 = 6*6 has two distinct factorizations.) - Franklin T. Adams-Watters, Sep 28 2013
These are also numbers k such that (k^k+1)/(k+1) is an integer. - Derek Orr, May 22 2014
a(n-1) gives the number of distinct sums in the direct sum {1,2,3,..,n} + {1,2,3,..,n}. For example, {1} + {1} has only one possible sum so a(0) = 1. {1,2} + {1,2} has three distinct possible sums {2,3,4} so a(1) = 3. {1,2,3} + {1,2,3} has 5 distinct possible sums {2,3,4,5,6} so a(2) = 5. - Derek Orr, Nov 22 2014
The number of partitions of 4*n into at most 2 parts. - Colin Barker, Mar 31 2015
a(n) is representable as a sum of two but no fewer consecutive nonnegative integers, e.g., 1 = 0 + 1, 3 = 1 + 2, 5 = 2 + 3, etc. (see A138591). - Martin Renner, Mar 14 2016
Unique solution a( ) of the complementary equation a(n) = a(n-1)^2 - a(n-2)*b(n-1), where a(0) = 1, a(1) = 3, and a( ) and b( ) are increasing complementary sequences. - Clark Kimberling, Nov 21 2017
Also the number of maximal and maximum cliques in the n-centipede graph. - Eric W. Weisstein, Dec 01 2017
Lexicographically earliest sequence of distinct positive integers such that the average of any number of consecutive terms is always an integer. (For opposite property see A042963.) - Ivan Neretin, Dec 21 2017
Maximum number of non-intersecting line segments between vertices of a convex (n+2)-gon. - Christoph B. Kassir, Oct 21 2022
a(n) is the number of parking functions of size n+1 avoiding the patterns 123, 132, and 231. - Lara Pudwell, Apr 10 2023

Examples

			G.f. = q + 3*q^3 + 5*q^5 + 7*q^7 + 9*q^9 + 11*q^11 + 13*q^13 + 15*q^15 + ...
		

References

  • T. M. Apostol, Introduction to Analytic Number Theory, Springer-Verlag, 1976, page 2.
  • John H. Conway and Richard K. Guy, The Book of Numbers, New York: Springer-Verlag, 1996. See p. 28.
  • T. Dantzig, The Language of Science, 4th Edition (1954) page 276.
  • H. Doerrie, 100 Great Problems of Elementary Mathematics, Dover, NY, 1965, p. 73.
  • Jan Gullberg, Mathematics from the Birth of Numbers, W. W. Norton & Co., NY & London, 1997, §8.1 Terminology, p. 264.
  • D. Hök, Parvisa mönster i permutationer [Swedish], (2007).
  • E. Maor, Trigonometric Delights, Princeton University Press, NJ, 1998, pp. 203-205.
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

See A120062 for sequences related to integer-sided triangles with integer inradius n.
Cf. A001651 (n=1 or 2 mod 3), A047209 (n=1 or 4 mod 5).
Cf. A003558, A216371, A179480 (relating to the Coach theorem).
Cf. A000754 (boustrophedon transform).

Programs

Formula

a(n) = 2*n + 1. a(-1 - n) = -a(n). a(n+1) = a(n) + 2.
G.f.: (1 + x) / (1 - x)^2.
E.g.f.: (1 + 2*x) * exp(x).
G.f. with interpolated zeros: (x^3+x)/((1-x)^2 * (1+x)^2); e.g.f. with interpolated zeros: x*(exp(x)+exp(-x))/2. - Geoffrey Critzer, Aug 25 2012
a(n) = L(n,-2)*(-1)^n, where L is defined as in A108299. - Reinhard Zumkeller, Jun 01 2005
Euler transform of length 2 sequence [3, -1]. - Michael Somos, Mar 30 2007
G.f. A(x) satisfies 0 = f(A(x), A(x^2)) where f(u, v) = v * (1 + 2*u) * (1 - 2*u + 16*v) - (u - 4*v)^2 * (1 + 2*u + 2*u^2). - Michael Somos, Mar 30 2007
a(n) = b(2*n + 1) where b(n) = n if n is odd is multiplicative. [This seems to say that A000027 is multiplicative? - R. J. Mathar, Sep 23 2011]
From Hieronymus Fischer, May 25 2007: (Start)
a(n) = (n+1)^2 - n^2.
G.f. g(x) = Sum_{k>=0} x^floor(sqrt(k)) = Sum_{k>=0} x^A000196(k). (End)
a(0) = 1, a(1) = 3, a(n) = 2*a(n-1) - a(n-2). - Jaume Oliver Lafont, May 07 2008
a(n) = A000330(A016777(n))/A000217(A016777(n)). - Pierre CAMI, Sep 27 2008
a(n) = A034856(n+1) - A000217(n) = A005843(n) + A000124(n) - A000217(n) = A005843(n) + 1. - Jaroslav Krizek, Sep 05 2009
a(n) = (n - 1) + n (sum of two sequential integers). - Dominick Cancilla, Aug 09 2010
a(n) = 4*A000217(n)+1 - 2*Sum_{i=1..n-1} a(i) for n > 1. - Bruno Berselli, Nov 17 2010
n*a(2n+1)^2+1 = (n+1)*a(2n)^2; e.g., 3*15^2+1 = 4*13^2. - Charlie Marion, Dec 31 2010
arctanh(x) = Sum_{n>=0} x^(2n+1)/a(n). - R. J. Mathar, Sep 23 2011
a(n) = det(f(i-j+1))A113311(n);%20for%20n%20%3C%200%20we%20have%20f(n)=0.%20-%20_Mircea%20Merca">{1<=i,j<=n}, where f(n) = A113311(n); for n < 0 we have f(n)=0. - _Mircea Merca, Jun 23 2012
G.f.: Q(0), where Q(k) = 1 + 2*(k+1)*x/( 1 - 1/(1 + 2*(k+1)/Q(k+1))); (continued fraction). - Sergei N. Gladkovskii, May 11 2013
a(n) = floor(sqrt(2*A000384(n+1))). - Ivan N. Ianakiev, Jun 17 2013
a(n) = 3*A000330(n)/A000217(n), n > 0. - Ivan N. Ianakiev, Jul 12 2013
a(n) = Product_{k=1..2*n} 2*sin(Pi*k/(2*n+1)) = Product_{k=1..n} (2*sin(Pi*k/(2*n+1)))^2, n >= 0 (undefined product = 1). See an Oct 09 2013 formula contribution in A000027 with a reference. - Wolfdieter Lang, Oct 10 2013
Noting that as n -> infinity, sqrt(n^2 + n) -> n + 1/2, let f(n) = n + 1/2 - sqrt(n^2 + n). Then for n > 0, a(n) = round(1/f(n))/4. - Richard R. Forberg, Feb 16 2014
a(n) = Sum_{k=0..n+1} binomial(2*n+1,2*k)*4^(k)*bernoulli(2*k). - Vladimir Kruchinin, Feb 24 2015
a(n) = Sum_{k=0..n} binomial(6*n+3, 6*k)*Bernoulli(6*k). - Michel Marcus, Jan 11 2016
a(n) = A000225(n+1) - A005803(n+1). - Miquel Cerda, Nov 25 2016
O.g.f.: Sum_{n >= 1} phi(2*n-1)*x^(n-1)/(1 - x^(2*n-1)), where phi(n) is the Euler totient function A000010. - Peter Bala, Mar 22 2019
Sum_{n>=0} 1/a(n)^2 = Pi^2/8 = A111003. - Bernard Schott, Dec 10 2020
Sum_{n >= 1} (-1)^n/(a(n)*a(n+1)) = Pi/4 - 1/2 = 1/(3 + (1*3)/(4 + (3*5)/(4 + ... + (4*n^2 - 1)/(4 + ... )))). Cf. A016754. - Peter Bala, Mar 28 2024
a(n) = A055112(n)/oblong(n) = A193218(n+1)/Hex number(n). Compare to the Sep 27 2008 comment by Pierre CAMI. - Klaus Purath, Apr 23 2024
a(k*m) = k*a(m) - (k-1). - Ya-Ping Lu, Jun 25 2024
a(n) = A000217(a(n))/n for n > 0. - Stefano Spezia, Feb 15 2025

Extensions

Incorrect comment and example removed by Joerg Arndt, Mar 11 2010
Peripheral comments deleted by N. J. A. Sloane, May 09 2022

A007814 Exponent of highest power of 2 dividing n, a.k.a. the binary carry sequence, the ruler sequence, or the 2-adic valuation of n.

Original entry on oeis.org

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

Views

Author

John Tromp, Dec 11 1996

Keywords

Comments

This sequence is an exception to my usual rule that when every other term of a sequence is 0 then those 0's should be omitted. In this case we would get A001511. - N. J. A. Sloane
To construct the sequence: start with 0,1, concatenate to get 0,1,0,1. Add + 1 to last term gives 0,1,0,2. Concatenate those 4 terms to get 0,1,0,2,0,1,0,2. Add + 1 to last term etc. - Benoit Cloitre, Mar 06 2003
The sequence is invariant under the following two transformations: increment every element by one (1, 2, 1, 3, 1, 2, 1, 4, ...), put a zero in front and between adjacent elements (0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, ...). The intermediate result is A001511. - Ralf Hinze (ralf(AT)informatik.uni-bonn.de), Aug 26 2003
Fixed point of the morphism 0->01, 1->02, 2->03, 3->04, ..., n->0(n+1), ..., starting from a(1) = 0. - Philippe Deléham, Mar 15 2004
Fixed point of the morphism 0->010, 1->2, 2->3, ..., n->(n+1), .... - Joerg Arndt, Apr 29 2014
a(n) is also the number of times to repeat a step on an even number in the hailstone sequence referenced in the Collatz conjecture. - Alex T. Flood (whiteangelsgrace(AT)gmail.com), Sep 22 2006
Let F(n) be the n-th Fermat number (A000215). Then F(a(r-1)) divides F(n)+2^k for r = k mod 2^n and r != 1. - T. D. Noe, Jul 12 2007
The following relation holds: 2^A007814(n)*(2*A025480(n-1)+1) = A001477(n) = n. (See functions hd, tl and cons in [Paul Tarau 2009].)
a(n) is the number of 0's at the end of n when n is written in base 2.
a(n+1) is the number of 1's at the end of n when n is written in base 2. - M. F. Hasler, Aug 25 2012
Shows which bit to flip when creating the binary reflected Gray code (bits are numbered from the right, offset is 0). That is, A003188(n) XOR A003188(n+1) == 2^A007814(n). - Russ Cox, Dec 04 2010
The sequence is squarefree (in the sense of not containing any subsequence of the form XX) [Allouche and Shallit]. Of course it contains individual terms that are squares (such as 4). - Comment expanded by N. J. A. Sloane, Jan 28 2019
a(n) is the number of zero coefficients in the n-th Stern polynomial, A125184. - T. D. Noe, Mar 01 2011
Lemma: For n < m with r = a(n) = a(m) there exists n < k < m with a(k) > r. Proof: We have n=b2^r and m=c2^r with b < c both odd; choose an even i between them; now a(i2^r) > r and n < i2^r < m. QED. Corollary: Every finite run of consecutive integers has a unique maximum 2-adic valuation. - Jason Kimberley, Sep 09 2011
a(n-2) is the 2-adic valuation of A000166(n) for n >= 2. - Joerg Arndt, Sep 06 2014
a(n) = number of 1's in the partition having Heinz number n. We define the Heinz number of a partition p = [p_1, p_2, ..., p_r] as Product_{j=1..r} p_j-th prime (concept used by Alois P. Heinz in A215366 as an "encoding" of a partition). For example, for the partition [1, 1, 2, 4, 10] we get 2*2*3*7*29 = 2436. Example: a(24)=3; indeed, the partition having Heinz number 24 = 2*2*2*3 is [1,1,1,2]. - Emeric Deutsch, Jun 04 2015
a(n+1) is the difference between the two largest parts in the integer partition having viabin number n (0 is assumed to be a part). Example: a(20) = 2. Indeed, we have 19 = 10011_2, leading to the Ferrers board of the partition [3,1,1]. For the definition of viabin number see the comment in A290253. - Emeric Deutsch, Aug 24 2017
Apart from being squarefree, as noted above, the sequence has the property that every consecutive subsequence contains at least one number an odd number of times. - Jon Richfield, Dec 20 2018
a(n+1) is the 2-adic valuation of Sum_{e=0..n} u^e = (1 + u + u^2 + ... + u^n), for any u of the form 4k+1 (A016813). - Antti Karttunen, Aug 15 2020
{a(n)} represents the "first black hat" strategy for the game of countably infinitely many hats, with a probability of success of 1/3; cf. the Numberphile link below. - Frederic Ruget, Jun 14 2021
a(n) is the least nonnegative integer k for which there does not exist i+j=n and a(i)=a(j)=k (cf. A322523). - Rémy Sigrist and Jianing Song, Aug 23 2022

Examples

			2^3 divides 24, so a(24)=3.
From _Omar E. Pol_, Jun 12 2009: (Start)
Triangle begins:
  0;
  1,0;
  2,0,1,0;
  3,0,1,0,2,0,1,0;
  4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0;
  5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0;
  6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,...
(End)
		

References

  • J.-P. Allouche and J. Shallit, Automatic Sequences, Cambridge Univ. Press, 2003, p. 27.
  • K. Atanassov, On the 37th and the 38th Smarandache Problems, Notes on Number Theory and Discrete Mathematics, Sophia, Bulgaria, Vol. 5 (1999), No. 2, 83-85.
  • Michel Rigo, Formal Languages, Automata and Numeration Systems, 2 vols., Wiley, 2014. Mentions this sequence - see "List of Sequences" in Vol. 2.

Crossrefs

Cf. A011371 (partial sums), A094267 (first differences), A001511 (bisection), A346070 (mod 4).
Bisection of A050605 and |A088705|. Pairwise sums are A050603 and A136480. Difference of A285406 and A281264.
This is Guy Steele's sequence GS(1, 4) (see A135416). Cf. A053398(1,n). Column/row 1 of table A050602.
Cf. A007949 (3-adic), A235127 (4-adic), A112765 (5-adic), A122841 (6-adic), A214411 (7-adic), A244413 (8-adic), A122840 (10-adic).
Cf. A086463 (Dgf at s=2).

Programs

  • Haskell
    a007814 n = if m == 0 then 1 + a007814 n' else 0
                where (n', m) = divMod n 2
    -- Reinhard Zumkeller, Jul 05 2013, May 14 2011, Apr 08 2011
    
  • Haskell
    a007814 n | odd n = 0 | otherwise = 1 + a007814 (n `div` 2)
    --  Walt Rorie-Baety, Mar 22 2013
    
  • Magma
    [Valuation(n, 2): n in [1..120]]; // Bruno Berselli, Aug 05 2013
    
  • Maple
    ord := proc(n) local i,j; if n=0 then return 0; fi; i:=0; j:=n; while j mod 2 <> 1 do i:=i+1; j:=j/2; od: i; end proc: seq(ord(n), n=1..111);
    A007814 := n -> padic[ordp](n,2): seq(A007814(n), n=1..111); # Peter Luschny, Nov 26 2010
  • Mathematica
    Table[IntegerExponent[n, 2], {n, 64}] (* Eric W. Weisstein *)
    IntegerExponent[Range[64], 2] (* Eric W. Weisstein, Feb 01 2024 *)
    p=2; Array[ If[ Mod[ #, p ]==0, Select[ FactorInteger[ # ], Function[ q, q[ [ 1 ] ]==p ], 1 ][ [ 1, 2 ] ], 0 ]&, 96 ]
    DigitCount[BitXor[x, x - 1], 2, 1] - 1; a different version based on the same concept: Floor[Log[2, BitXor[x, x - 1]]] (* Jaume Simon Gispert (jaume(AT)nuem.com), Aug 29 2004 *)
    Nest[Join[ #, ReplacePart[ #, Length[ # ] -> Last[ # ] + 1]] &, {0, 1}, 5] (* N. J. Gunther, May 23 2009 *)
    Nest[ Flatten[# /. a_Integer -> {0, a + 1}] &, {0}, 7] (* Robert G. Wilson v, Jan 17 2011 *)
  • PARI
    A007814(n)=valuation(n,2);
    
  • Python
    import math
    def a(n): return int(math.log(n - (n & n - 1), 2)) # Indranil Ghosh, Apr 18 2017
    
  • Python
    def A007814(n): return (~n & n-1).bit_length() # Chai Wah Wu, Jul 01 2022
    
  • R
    sapply(1:100,function(x) sum(gmp::factorize(x)==2)) # Christian N. K. Anderson, Jun 20 2013
    
  • Scheme
    (define (A007814 n) (let loop ((n n) (e 0)) (if (odd? n) e (loop (/ n 2) (+ 1 e))))) ;; Antti Karttunen, Oct 06 2017

Formula

a(n) = A001511(n) - 1.
a(2*n) = A050603(2*n) = A001511(n).
a(n) = A091090(n-1) + A036987(n-1) - 1.
a(n) = 0 if n is odd, otherwise 1 + a(n/2). - Reinhard Zumkeller, Aug 11 2001
Sum_{k=1..n} a(k) = n - A000120(n). - Benoit Cloitre, Oct 19 2002
G.f.: A(x) = Sum_{k>=1} x^(2^k)/(1-x^(2^k)). - Ralf Stephan, Apr 10 2002
G.f. A(x) satisfies A(x) = A(x^2) + x^2/(1-x^2). A(x) = B(x^2) = B(x) - x/(1-x), where B(x) is the g.f. for A001151. - Franklin T. Adams-Watters, Feb 09 2006
Totally additive with a(p) = 1 if p = 2, 0 otherwise.
Dirichlet g.f.: zeta(s)/(2^s-1). - Ralf Stephan, Jun 17 2007
Define 0 <= k <= 2^n - 1; binary: k = b(0) + 2*b(1) + 4*b(2) + ... + 2^(n-1)*b(n-1); where b(x) are 0 or 1 for 0 <= x <= n - 1; define c(x) = 1 - b(x) for 0 <= x <= n - 1; Then: a(k) = c(0) + c(0)*c(1) + c(0)*c(1)*c(2) + ... + c(0)*c(1)...c(n-1); a(k+1) = b(0) + b(0)*b(1) + b(0)*b(1)*b(2) + ... + b(0)*b(1)...b(n-1). - Arie Werksma (werksma(AT)tiscali.nl), May 10 2008
a(n) = floor(A002487(n - 1) / A002487(n)). - Reikku Kulon, Oct 05 2008
Sum_{k=1..n} (-1)^A000120(n-k)*a(k) = (-1)^(A000120(n)-1)*(A000120(n) - A000035(n)). - Vladimir Shevelev, Mar 17 2009
a(A001147(n) + A057077(n-1)) = a(2*n). - Vladimir Shevelev, Mar 21 2009
For n>=1, a(A004760(n+1)) = a(n). - Vladimir Shevelev, Apr 15 2009
2^(a(n)) = A006519(n). - Philippe Deléham, Apr 22 2009
a(n) = A063787(n) - A000120(n). - Gary W. Adamson, Jun 04 2009
a(C(n,k)) = A000120(k) + A000120(n-k) - A000120(n). - Vladimir Shevelev, Jul 19 2009
a(n!) = n - A000120(n). - Vladimir Shevelev, Jul 20 2009
v_{2}(n) = Sum_{r>=1} (r / 2^(r+1)) Sum_{k=0..2^(r+1)-1} e^(2(k*Pi*i(n+2^r))/(2^(r+1))). - A. Neves, Sep 28 2010, corrected Oct 04 2010
a(n) mod 2 = A096268(n-1). - Robert G. Wilson v, Jan 18 2012
a(A005408(n)) = 1; a(A016825(n)) = 3; A017113(a(n)) = 5; A051062(a(n)) = 7; a(n) = (A037227(n)-1)/2. - Reinhard Zumkeller, Jun 30 2012
a((2*n-1)*2^p) = p, p >= 0 and n >= 1. - Johannes W. Meijer, Feb 04 2013
a(n) = A067255(n,1). - Reinhard Zumkeller, Jun 11 2013
a(n) = log_2(n - (n AND n-1)). - Gary Detlefs, Jun 13 2014
a(n) = 1 + A000120(n-1) - A000120(n), where A000120 is the Hamming weight function. - Stanislav Sykora, Jul 14 2014
A053398(n,k) = a(A003986(n-1,k-1)+1); a(n) = A053398(n,1) = A053398(n,n) = A053398(2*n-1,n) = Min_{k=1..n} A053398(n,k). - Reinhard Zumkeller, Aug 04 2014
a((2*x-1)*2^n) = a((2*y-1)*2^n) for positive n, x and y. - Juri-Stepan Gerasimov, Aug 04 2016
a(n) = A285406(n) - A281264(n). - Ralf Steiner, Apr 18 2017
a(n) = A000005(n)/(A000005(2*n) - A000005(n)) - 1. - conjectured by Velin Yanev, Jun 30 2017, proved by Nicholas Stearns, Sep 11 2017
Equivalently to above formula, a(n) = A183063(n) / A001227(n), i.e., a(n) is the number of even divisors of n divided by number of odd divisors of n. - Franklin T. Adams-Watters, Oct 31 2018
a(n)*(n mod 4) = 2*floor(((n+1) mod 4)/3). - Gary Detlefs, Feb 16 2019
Asymptotic mean: lim_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 1. - Amiram Eldar, Jul 11 2020
a(n) = 2*Sum_{j=1..floor(log_2(n))} frac(binomial(n, 2^j)*2^(j-1)/n). - Dario T. de Castro, Jul 08 2022
a(n) = A070939(n) - A070939(A030101(n)). - Andrew T. Porter, Dec 16 2022
a(n) = floor((gcd(n, 2^n)^(n+1) mod (2^(n+1)-1)^2)/(2^(n+1)-1)) (see Lemma 3.4 from Mazzanti's 2002 article). - Lorenzo Sauras Altuzarra, Mar 10 2024
a(n) = 1 - A088705(n). - Chai Wah Wu, Sep 18 2024

Extensions

Formula index adapted to the offset of A025480 by R. J. Mathar, Jul 20 2010
Edited by Ralf Stephan, Feb 08 2014

A002487 Stern's diatomic series (or Stern-Brocot sequence): a(0) = 0, a(1) = 1; for n > 0: a(2*n) = a(n), a(2*n+1) = a(n) + a(n+1).

Original entry on oeis.org

0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 5, 2, 5, 3, 4, 1, 5, 4, 7, 3, 8, 5, 7, 2, 7, 5, 8, 3, 7, 4, 5, 1, 6, 5, 9, 4, 11, 7, 10, 3, 11, 8, 13, 5, 12, 7, 9, 2, 9, 7, 12, 5, 13, 8, 11, 3, 10, 7, 11, 4, 9, 5, 6, 1, 7, 6, 11, 5, 14, 9, 13, 4, 15, 11, 18, 7, 17, 10, 13, 3, 14, 11, 19, 8, 21, 13, 18, 5, 17, 12, 19
Offset: 0

Views

Author

Keywords

Comments

Also called fusc(n) [Dijkstra].
a(n)/a(n+1) runs through all the reduced nonnegative rationals exactly once [Stern; Calkin and Wilf].
If the terms are written as an array:
column 0 1 2 3 4 5 6 7 8 9 ...
row 0: 0
row 1: 1
row 2: 1,2
row 3: 1,3,2,3
row 4: 1,4,3,5,2,5,3,4
row 5: 1,5,4,7,3,8,5,7,2,7,5,8,3,7,4,5
row 6: 1,6,5,9,4,11,7,10,3,11,8,13,5,12,7,9,2,9,7,12,5,13,8,11,3,10,...
...
then (ignoring row 0) the sum of the k-th row is 3^(k-1), each column is an arithmetic progression and the steps are nothing but the original sequence. - Takashi Tokita (butaneko(AT)fa2.so-net.ne.jp), Mar 08 2003
From N. J. A. Sloane, Oct 15 2017: (Start)
The above observation can be made more precise. Let A(n,k), n >= 0, 0 <= k <= 2^(n-1)-1 for k > 0, denote the entry in row n and column k of the left-justified array above.
The equations for columns 0,1,2,3,4,... are successively (ignoring row 0):
1 (n >= 1),
n (n >= 2),
n-1 (n >= 3),
2n-3 (n >= 3),
n-2 (n >= 4),
3n-7 (n >= 4),
...
and in general column k > 0 is given by
A(n,k) = a(k)*n - A156140(k) for n >= ceiling(log_2(k+1))+1, and 0 otherwise.
(End)
a(n) is the number of odd Stirling numbers S_2(n+1, 2r+1) [Carlitz].
Moshe Newman proved that the fraction a(n+1)/a(n+2) can be generated from the previous fraction a(n)/a(n+1) = x by 1/(2*floor(x) + 1 - x). The successor function f(x) = 1/(floor(x) + 1 - frac(x)) can also be used.
a(n+1) = number of alternating bit sets in n [Finch].
If f(x) = 1/(1 + floor(x) - frac(x)) then f(a(n-1)/a(n)) = a(n)/a(n+1) for n >= 1. If T(x) = -1/x and f(x) = y, then f(T(y)) = T(x) for x > 0. - Michael Somos, Sep 03 2006
a(n+1) is the number of ways of writing n as a sum of powers of 2, each power being used at most twice (the number of hyperbinary representations of n) [Carlitz; Lind].
a(n+1) is the number of partitions of the n-th integer expressible as the sum of distinct even-subscripted Fibonacci numbers (= A054204(n)), into sums of distinct Fibonacci numbers [Bicknell-Johnson, theorem 2.1].
a(n+1) is the number of odd binomial(n-k, k), 0 <= 2*k <= n. [Carlitz], corrected by Alessandro De Luca, Jun 11 2014
a(2^k) = 1. a(3*2^k) = a(2^(k+1) + 2^k) = 2. Sequences of terms between a(2^k) = 1 and a(2^(k+1)) = 1 are palindromes of length 2^k-1 with a(2^k + 2^(k-1)) = 2 in the middle. a(2^(k-1) + 1) = a(2^k - 1) = k+1 for k > 1. - Alexander Adamchuk, Oct 10 2006
The coefficients of the inverse of the g.f. of this sequence form A073469 and are related to binary partitions A000123. - Philippe Flajolet, Sep 06 2008
It appears that the terms of this sequence are the number of odd entries in the diagonals of Pascal's triangle at 45 degrees slope. - Javier Torres (adaycalledzero(AT)hotmail.com), Aug 06 2009
Let M be an infinite lower triangular matrix with (1, 1, 1, 0, 0, 0, ...) in every column shifted down twice:
1;
1, 0;
1, 1, 0;
0, 1, 0, 0;
0, 1, 1, 0, 0;
0, 0, 1, 0, 0, 0;
0, 0, 1, 1, 0, 0, 0;
...
Then this sequence A002487 (without initial 0) is the first column of lim_{n->oo} M^n. (Cf. A026741.) - Gary W. Adamson, Dec 11 2009 [Edited by M. F. Hasler, Feb 12 2017]
Member of the infinite family of sequences of the form a(n) = a(2*n); a(2*n+1) = r*a(n) + a(n+1), r = 1 for A002487 = row 1 in the array of A178239. - Gary W. Adamson, May 23 2010
Equals row 1 in an infinite array shown in A178568, sequences of the form
a(2*n) = r*a(n), a(2*n+1) = a(n) + a(n+1); r = 1. - Gary W. Adamson, May 29 2010
Row sums of A125184, the Stern polynomials. Equivalently, B(n,1), the n-th Stern polynomial evaluated at x = 1. - T. D. Noe, Feb 28 2011
The Kn1y and Kn2y triangle sums, see A180662 for their definitions, of A047999 lead to the sequence given above, e.g., Kn11(n) = A002487(n+1) - A000004(n), Kn12(n) = A002487(n+3) - A000012(n), Kn13(n) = A002487(n+5) - A000034(n+1) and Kn14(n) = A002487(n+7) - A157810(n+1). For the general case of the knight triangle sums see the Stern-Sierpiński triangle A191372. This triangle not only leads to Stern's diatomic series but also to snippets of this sequence and, quite surprisingly, their reverse. - Johannes W. Meijer, Jun 05 2011
Maximum of terms between a(2^k) = 1 and a(2^(k+1)) = 1 is the Fibonacci number F(k+2). - Leonid Bedratyuk, Jul 04 2012
Probably the number of different entries per antidiagonal of A223541. That would mean there are exactly a(n+1) numbers that can be expressed as a nim-product 2^x*2^y with x + y = n. - Tilman Piesk, Mar 27 2013
Let f(m,n) be the frequency of the integer n in the interval [a(2^(m-1)), a(2^m-1)]. Let phi(n) be Euler's totient function (A000010). Conjecture: for all integers m,n n<=m f(m,n) = phi(n). - Yosu Yurramendi, Sep 08 2014
Back in May 1995, it was proved that A000360 is the modulo 3 mapping, (+1,-1,+0)/2, of this sequence A002487 (without initial 0). - M. Jeremie Lafitte (Levitas), Apr 24 2017
Define a sequence chf(n) of Christoffel words over an alphabet {-,+}: chf(1) = '-'; chf(2*n+0) = negate(chf(n)); chf(2*n+1) = negate(concatenate(chf(n),chf(n+1))). Then the length of the chf(n) word is fusc(n) = a(n); the number of '-'-signs in the chf(n) word is c-fusc(n) = A287729(n); the number of '+'-signs in the chf(n) word is s-fusc(n) = A287730(n). See examples below. - I. V. Serov, Jun 01 2017
The sequence can be extended so that a(n) = a(-n), a(2*n) = a(n), a(2*n+1) = a(n) + a(n+1) for all n in Z. - Michael Somos, Jun 25 2019
Named after the German mathematician Moritz Abraham Stern (1807-1894), and sometimes also after the French clockmaker and amateur mathematician Achille Brocot (1817-1878). - Amiram Eldar, Jun 06 2021
It appears that a(n) is equal to the multiplicative inverse of A007305(n+1) mod A007306(n+1). For example, a(12) is 2, the multiplicative inverse of A007305(13) mod A007306(13), where A007305(13) is 4 and A007306(13) is 7. - Gary W. Adamson, Dec 18 2023

Examples

			Stern's diatomic array begins:
  1,1,
  1,2,1,
  1,3,2,3,1,
  1,4,3,5,2,5,3,4,1,
  1,5,4,7,3,8,5,7,2,7,5,8,3,7,4,5,1,
  1,6,5,9,4,11,7,10,3,11,8,13,5,12,7,9,2,9,7,12,5,13,8,11,3,10,7,11,4,9,...
  ...
a(91) = 19, because 91_10 = 1011011_2; b_6=b_4=b_3=b_1=b_0=1, b_5=b_2=0;  L=5; m_1=0, m_2=1, m_3=3, m_4=4, m_5=6; c_1=2, c_2=3, c_3=2, c_4=3; f(1)=1, f(2)=2, f(3)=5, f(4)=8, f(5)=19. - _Yosu Yurramendi_, Jul 13 2016
From _I. V. Serov_, Jun 01 2017: (Start)
a(n) is the length of the Christoffel word chf(n):
n  chf(n) A070939(n)   a(n)
1   '-'       1          1
2   '+'       2          1
3   '+-'      2          2
4   '-'       3          1
5   '--+'     3          3
6   '-+'      3          2
... (End)
G.f. = x + x^2 + 2*x^3 + x^4 + 3*x^5 + 2*x^6 + 3*x^7 + x^8 + ... - _Michael Somos_, Jun 25 2019
		

References

  • M. Aigner and G. M. Ziegler, Proofs from THE BOOK, 3rd ed., Berlin, Heidelberg, New York: Springer-Verlag, 2004, p. 97.
  • Elwyn R. Berlekamp, John H. Conway and Richard K. Guy, Winning Ways, Academic Press, NY, 2 vols., 1982, see p. 114.
  • Krishna Dasaratha, Laure Flapan, Chansoo Lee, Cornelia Mihaila, Nicholas Neumann-Chun, Sarah Peluse and Matthew Stroegeny, A family of multi-dimensional continued fraction Stern sequences, Abtracts Amer. Math. Soc., Vol. 33 (#1, 2012), #1077-05-2543.
  • Edsger W. Dijkstra, Selected Writings on Computing, Springer, 1982, p. 232 (sequence is called fusc).
  • F. G. M. Eisenstein, Eine neue Gattung zahlentheoretischer Funktionen, welche von zwei Elementen abhaengen und durch gewisse lineare Funktional-Gleichungen definirt werden, Verhandlungen der Koenigl. Preuss. Akademie der Wiss. Berlin (1850), pp. 36-42, Feb 18, 1850. Werke, II, pp. 705-711.
  • Graham Everest, Alf van der Poorten, Igor Shparlinski and Thomas Ward, Recurrence Sequences, Amer. Math. Soc., 2003; see esp. p. 255.
  • Steven R. Finch, Mathematical Constants, Cambridge, 2003, Section 2.16.3; pp. 148-149.
  • Ronald L. Graham, Donald E. Knuth and Oren Patashnik, Concrete Mathematics. Addison-Wesley, Reading, MA, 1990, p. 117.
  • Thomas Koshy, Fibonacci and Lucas numbers with applications, Wiley, 2001, p. 98.
  • 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

Record values are in A212289.
If the 1's are replaced by pairs of 1's we obtain A049456.
Inverse: A020946.
Cf. a(A001045(n)) = A000045(n). a(A062092(n)) = A000032(n+1).
Cf. A064881-A064886 (Stern-Brocot subtrees).
A column of A072170.
Cf. A049455 for the 0,1 version of Stern's diatomic array.
Cf. A000119, A262097 for analogous sequences in other bases and A277189, A277315, A277328 for related sequences with similar graphs.
Cf. A086592 and references therein to other sequences related to Kepler's tree of fractions.

Programs

  • Haskell
    a002487 n = a002487_list !! n
    a002487_list = 0 : 1 : stern [1] where
       stern fuscs = fuscs' ++ stern fuscs' where
         fuscs' = interleave fuscs $ zipWith (+) fuscs $ (tail fuscs) ++ [1]
       interleave []     ys = ys
       interleave (x:xs) ys = x : interleave ys xs
    -- Reinhard Zumkeller, Aug 23 2011
    
  • Julia
    using Nemo
    function A002487List(len)
        a, A = QQ(0), [0,1]
        for n in 1:len
            a = next_calkin_wilf(a)
            push!(A, denominator(a))
        end
    A end
    A002487List(91) |> println # Peter Luschny, Mar 13 2018
    
  • Magma
    [&+[(Binomial(k, n-k-1) mod 2): k in [0..n]]: n in [0..100]]; // Vincenzo Librandi, Jun 18 2019
    
  • Maple
    A002487 := proc(n) option remember; if n <= 1 then n elif n mod 2 = 0 then procname(n/2); else procname((n-1)/2)+procname((n+1)/2); fi; end: seq(A002487(n),n=0..91);
    A002487 := proc(m) local a,b,n; a := 1; b := 0; n := m; while n>0 do if type(n,odd) then b := a+b else a := a+b end if; n := floor(n/2); end do; b; end proc: seq(A002487(n),n=0..91); # Program adapted from E. Dijkstra, Selected Writings on Computing, Springer, 1982, p. 232. - Igor Urbiha (urbiha(AT)math.hr), Oct 28 2002. Since A007306(n) = a(2*n+1), this program can be adapted for A007306 by replacing b := 0 by b := 1.
    A002487 := proc(n::integer) local k; option remember; if n = 0 then 0 elif n=1 then 1 else add(K(k,n-1-k)*procname(n - k), k = 1 .. n) end if end proc:
    K := proc(n::integer, k::integer) local KC; if 0 <= k and k <= n and n-k <= 2 then KC:=1; else KC:= 0; end if; end proc: seq(A002487(n),n=0..91); # Thomas Wieder, Jan 13 2008
    # next Maple program:
    a:= proc(n) option remember; `if`(n<2, n,
          (q-> a(q)+(n-2*q)*a(n-q))(iquo(n, 2)))
        end:
    seq(a(n), n=0..100);  # Alois P. Heinz, Feb 11 2021
    fusc := proc(n) local a, b, c; a := 1; b := 0;
        for c in convert(n, base, 2) do
            if c = 0 then a := a + b else b := a + b fi od;
        b end:
    seq(fusc(n), n = 0..91); # Peter Luschny, Nov 09 2022
    Stern := proc(n, u) local k, j, b;
        b := j -> nops({seq(Bits:-Xor(k, j-k), k = 0..j)}):
        ifelse(n=0, 1-u, seq(b(j), j = 2^(n-1)-1..2^n-1-u)) end:
    seq(print([n], Stern(n, 1)), n = 0..5); # As shown in the comments.
    seq(print([n], Stern(n, 0)), n = 0..5); # As shown in the examples. # Peter Luschny, Sep 29 2024
  • Mathematica
    a[0] = 0; a[1] = 1; a[n_] := If[ EvenQ[n], a[n/2], a[(n-1)/2] + a[(n+1)/2]]; Table[ a[n], {n, 0, 100}] (* end of program *)
    Onemore[l_] := Transpose[{l, l + RotateLeft[l]}] // Flatten;
    NestList[Onemore, {1}, 5] // Flatten  (*gives [a(1), ...]*) (* Takashi Tokita, Mar 09 2003 *)
    ToBi[l_] := Table[2^(n - 1), {n, Length[l]}].Reverse[l]; Map[Length,
    Split[Sort[Map[ToBi, Table[IntegerDigits[n - 1, 3], {n, 500}]]]]]  (*give [a(1), ...]*) (* Takashi Tokita, Mar 10 2003 *)
    A002487[m_] := Module[{a = 1, b = 0, n = m}, While[n > 0, If[OddQ[n], b = a+b, a = a+b]; n = Floor[n/2]]; b]; Table[A002487[n], {n, 0, 100}] (* Jean-François Alcover, Sep 06 2013, translated from 2nd Maple program *)
    a[0] = 0; a[1] = 1;
    Flatten[Table[{a[2*n] = a[n], a[2*n + 1] = a[n] + a[n + 1]}, {n, 0, 50}]] (* Horst H. Manninger, Jun 09 2021 *)
    nmax = 100; CoefficientList[Series[x*Product[(1 + x^(2^k) + x^(2^(k+1))), {k, 0, Floor[Log[2, nmax]] + 1}], {x, 0, nmax}], x] (* Vaclav Kotesovec, Oct 08 2022 *)
  • PARI
    {a(n) = n=abs(n); if( n<2, n>0, a(n\2) + if( n%2, a(n\2 + 1)))};
    
  • PARI
    fusc(n)=local(a=1,b=0);while(n>0,if(bitand(n,1),b+=a,a+=b);n>>=1);b \\ Charles R Greathouse IV, Oct 05 2008
    
  • PARI
    A002487(n,a=1,b=0)=for(i=0,logint(n,2),if(bittest(n,i),b+=a,a+=b));b \\ M. F. Hasler, Feb 12 2017, updated Feb 14 2019
    
  • Python
    from functools import lru_cache
    @lru_cache(maxsize=None)
    def a(n): return n if n<2 else a(n//2) if n%2==0 else a((n - 1)//2) + a((n + 1)//2) # Indranil Ghosh, Jun 08 2017; corrected by Reza K Ghazi, Dec 27 2021
    
  • Python
    def a(n):
        a, b = 1, 0
        while n > 0:
            if n & 1:
                b += a
            else:
                a += b
            n >>= 1
        return b
    # Reza K Ghazi, Dec 29 2021
    
  • Python
    def A002487(n): return sum(int(not (n-k-1) & ~k) for k in range(n)) # Chai Wah Wu, Jun 19 2022
    
  • Python
    # (fast way for big vectors)
    from math import log, ceil
    import numpy
    how_many_terms = 2**20  # (Powers of 2 recommended but other integers are also possible.)
    A002487, A002487[1]  = numpy.zeros(2**(ce:=ceil(log(how_many_terms,2))), dtype=object), 1
    for exponent in range(1,ce):
        L, L2 = 2**exponent, 2**(exponent+1)
        A002487[L2 - 1] = exponent + 1
        A002487[L:L2][::2] = A002487[L >> 1: L]
        A002487[L + 1:L2 - 2][::2] = A002487[L:L2 - 3][::2]  +  A002487[L + 2:L2 - 1][::2]
    print(list(A002487[0:100])) # Karl-Heinz Hofmann, Jul 22 2025
  • R
    N <- 50 # arbitrary
    a <- 1
    for (n in 1:N)
    {
      a[2*n    ] = a[n]
      a[2*n + 1] = a[n] + a[n+1]
      a
    }
    a
    # Yosu Yurramendi, Oct 04 2014
    
  • R
    # Given n, compute a(n) by taking into account the binary representation of n
    a <- function(n){
      b <- as.numeric(intToBits(n))
      l <- sum(b)
      m <- which(b == 1)-1
      d <- 1
      if(l > 1) for(j in 1:(l-1)) d[j] <- m[j+1]-m[j]+1
      f <- c(0,1)
      if(l > 1) for(j in 3:(l+1)) f[j] <- d[j-2]*f[j-1]-f[j-2]
      return(f[l+1])
    } # Yosu Yurramendi, Dec 13 2016
    
  • R
    # computes the sequence as a vector A, rather than function a() as above.
    A <- c(1,1)
    maxlevel <- 5 # by choice
    for(m in 1:maxlevel) {
      A[2^(m+1)] <- 1
      for(k in 1:(2^m-1)) {
        r <- m - floor(log2(k)) - 1
        A[2^r*(2*k+1)] <- A[2^r*(2*k)] + A[2^r*(2*k+2)]
    }}
    A # Yosu Yurramendi, May 08 2018
    
  • Sage
    def A002487(n):
        M = [1, 0]
        for b in n.bits():
            M[b] = M[0] + M[1]
        return M[1]
    print([A002487(n) for n in (0..91)])
    # For a dual see A174980. Peter Luschny, Nov 28 2017
    
  • Scheme
    ;; An implementation of memoization-macro definec can be found for example in: http://oeis.org/wiki/Memoization
    (definec (A002487 n) (cond ((<= n 1) n) ((even? n) (A002487 (/ n 2))) (else (+ (A002487 (/ (- n 1) 2)) (A002487 (/ (+ n 1) 2))))))
    ;; Antti Karttunen, Nov 05 2016
    

Formula

a(n+1) = (2*k+1)*a(n) - a(n-1) where k = floor(a(n-1)/a(n)). - David S. Newman, Mar 04 2001
Let e(n) = A007814(n) = exponent of highest power of 2 dividing n. Then a(n+1) = (2k+1)*a(n)-a(n-1), n > 0, where k = e(n). Moreover, floor(a(n-1)/a(n)) = e(n), in agreement with D. Newman's formula. - Dragutin Svrtan (dsvrtan(AT)math.hr) and Igor Urbiha (urbiha(AT)math.hr), Jan 10 2002
Calkin and Wilf showed 0.9588 <= limsup a(n)/n^(log(phi)/log(2)) <= 1.1709 where phi is the golden mean. Does this supremum limit = 1? - Benoit Cloitre, Jan 18 2004. Coons and Tyler show the limit is A246765 = 0.9588... - Kevin Ryde, Jan 09 2021
a(n) = Sum_{k=0..floor((n-1)/2)} (binomial(n-k-1, k) mod 2). - Paul Barry, Sep 13 2004
a(n) = Sum_{k=0..n-1} (binomial(k, n-k-1) mod 2). - Paul Barry, Mar 26 2005
G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^4)) where f(u, v, w) = v^3 + 2*u*v*w - u^2*w. - Michael Somos, May 02 2005
G.f. A(x) satisfies 0 = f(A(x), A(x^2), A(x^3), A(x^6)) where f(u1, u2, u3, u6) = u1^3*u6 - 3*u1^2*u2*u6 + 3*u2^3*u6 - u2^3*u3. - Michael Somos, May 02 2005
G.f.: x * Product_{k>=0} (1 + x^(2^k) + x^(2^(k+1))) [Carlitz].
a(n) = a(n-2) + a(n-1) - 2*(a(n-2) mod a(n-1)). - Mike Stay, Nov 06 2006
A079978(n) = (1 + e^(i*Pi*A002487(n)))/2, i=sqrt(-1). - Paul Barry, Jan 14 2005
a(n) = Sum_{k=1..n} K(k, n-k)*a(n - k), where K(n,k) = 1 if 0 <= k AND k <= n AND n-k <= 2 and K(n,k) = 0 else. (When using such a K-coefficient, several different arguments to K or several different definitions of K may lead to the same integer sequence. For example, if we drop the condition k <= n in the above definition, then we arrive at A002083 = Narayana-Zidek-Capell numbers.) - Thomas Wieder, Jan 13 2008
a(k+1)*a(2^n - k) - a(k)*a(2^n - (k+1)) = 1; a(2^n - k) + a(k) = a(2^(n+1) + k). Both formulas hold for 0 <= k <= 2^n - 1. G.f.: G(z) = a(1) + a(2)*z + a(3)*z^2 + ... + a(k+1)*z^k + ... Define f(z) = (1 + z + z^2), then G(z) = lim f(z)*f(z^2)*f(z^4)* ... *f(z^(2^n))*... = (1 + z + z^2)*G(z^2). - Arie Werksma (werksma(AT)tiscali.nl), Apr 11 2008
a(k+1)*a(2^n - k) - a(k)*a(2^n - (k+1)) = 1 (0 <= k <= 2^n - 1). - Arie Werksma (werksma(AT)tiscali.nl), Apr 18 2008
a(2^n + k) = a(2^n - k) + a(k) (0 <= k <= 2^n). - Arie Werksma (werksma(AT)tiscali.nl), Apr 18 2008
Let g(z) = a(1) + a(2)*z + a(3)*z^2 + ... + a(k+1)*z^k + ..., f(z) = 1 + z + z^2. Then g(z) = lim_{n->infinity} f(z)*f(z^2)*f(z^4)*...*f(z^(2^n)), g(z) = f(z)*g(z^2). - Arie Werksma (werksma(AT)tiscali.nl), Apr 18 2008
For 0 <= k <= 2^n - 1, write k = b(0) + 2*b(1) + 4*b(2) + ... + 2^(n-1)*b(n-1) where b(0), b(1), etc. are 0 or 1. Define a 2 X 2 matrix X(m) with entries x(1,1) = x(2,2) = 1, x(1,2) = 1 - b(m), x(2,1) = b(m). Let P(n)= X(0)*X(1)* ... *X(n-1). The entries of the matrix P are members of the sequence: p(1,1) = a(k+1), p(1,2) = a(2^n - (k+1)), p(2,1) = a(k), p(2,2) = a(2^n - k). - Arie Werksma (werksma(AT)tiscali.nl), Apr 20 2008
Let f(x) = A030101(x); if 2^n + 1 <= x <= 2^(n + 1) and y = 2^(n + 1) - f(x - 1) then a(x) = a(y). - Arie Werksma (Werksma(AT)Tiscali.nl), Jul 11 2008
a(n) = A126606(n + 1) / 2. - Reikku Kulon, Oct 05 2008
Equals infinite convolution product of [1,1,1,0,0,0,0,0,0] aerated A000079 - 1 times, i.e., [1,1,1,0,0,0,0,0,0] * [1,0,1,0,1,0,0,0,0] * [1,0,0,0,1,0,0,0,1]. - Mats Granvik and Gary W. Adamson, Oct 02 2009; corrected by Mats Granvik, Oct 10 2009
a(2^(p+2)*n+2^(p+1)-1) - a(2^(p+1)*n+2^p-1) = A007306(n+1), p >= 0 and n >= 0. - Johannes W. Meijer, Feb 07 2013
a(2*n-1) = A007306(n), n > 0. - Yosu Yurramendi, Jun 23 2014
a(n*2^m) = a(n), m>0, n > 0. - Yosu Yurramendi, Jul 03 2014
a(k+1)*a(2^m+k) - a(k)*a(2^m+(k+1)) = 1 for m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Nov 07 2014
a(2^(m+1)+(k+1))*a(2^m+k) - a(2^(m+1)+k)*a(2^m+(k+1)) = 1 for m >= 0, 0 <= k < 2^m. - Yosu Yurramendi, Nov 07 2014
a(5*2^k) = 3. a(7*2^k) = 3. a(9*2^k) = 4. a(11*2^k) = 5. a(13*2^k) = 5. a(15*2^k) = 4. In general: a((2j-1)*2^k) = A007306(j), j > 0, k >= 0 (see Adamchuk's comment). - Yosu Yurramendi, Mar 05 2016
a(2^m+2^m'+k') = a(2^m'+k')*(m-m'+1) - a(k'), m >= 0, m' <= m-1, 0 <= k' < 2^m'. - Yosu Yurramendi, Jul 13 2016
From Yosu Yurramendi, Jul 13 2016: (Start)
Let n be a natural number and [b_m b_(m-1) ... b_1 b_0] its binary expansion with b_m=1.
Let L = Sum_{i=0..m} b_i be the number of binary digits equal to 1 (L >= 1).
Let {m_j: j=1..L} be the set of subindices such that b_m_j = 1, j=1..L, and 0 <= m_1 <= m_2 <= ... <= m_L = m.
If L = 1 then c_1 = 1, otherwise let {c_j: j=1..(L-1)} be the set of coefficients such that c_(j) = m_(j+1) - m_j + 1, 1 <= j <= L-1.
Let f be a function defined on {1..L+1} such that f(1) = 0, f(2) = 1, f(j) = c_(j-2)*f(j-1) - f(j-2), 3 <= j <= L+1.
Then a(n) = f(L+1) (see example). (End)
a(n) = A001222(A260443(n)) = A000120(A277020(n)). Also a(n) = A000120(A101624(n-1)) for n >= 1. - Antti Karttunen, Nov 05 2016
(a(n-1) + a(n+1))/a(n) = A037227(n) for n >= 1. - Peter Bala, Feb 07 2017
a(0) = 0; a(3n) = 2*A000360(3n-1); a(3n+1) = 2*A000360(3n) - 1; a(3n+2) = 2*A000360(3n+1) + 1. - M. Jeremie Lafitte (Levitas), Apr 24 2017
From I. V. Serov, Jun 14 2017: (Start)
a(n) = A287896(n-1) - 1*A288002(n-1) for n > 1;
a(n) = A007306(n-1) - 2*A288002(n-1) for n > 1. (End)
From Yosu Yurramendi, Feb 14 2018: (Start)
a(2^(m+2) + 2^(m+1) + k) - a(2^(m+1) + 2^m + k) = 2*a(k), m >= 0, 0 <= k < 2^m.
a(2^(m+2) + 2^(m+1) + k) - a(2^(m+1) + k) = a(2^m + k), m >= 0, 0 <= k < 2^m.
a(2^m + k) = a(k)*(m - floor(log_2(k)) - 1) + a(2^(floor(log_2(k))+1) + k), m >= 0, 0 < k < 2^m, a(2^m) = 1, a(0) = 0. (End)
From Yosu Yurramendi, May 08 2018: (Start)
a(2^m) = 1, m >= 0.
a(2^r*(2*k+1)) = a(2^r*(2*k)) + a(2^r*(2*k+2)), r < - m - floor(log_2(k)) - 1, m > 0, 1 <= k < 2^m. (End)
Trow(n) = [card({k XOR (j-k): k=0..j}) for j = 2^(n-1)-1..2^n-2] when regarded as an irregular table (n >= 1). - Peter Luschny, Sep 29 2024
a(n) = A000120(A168081(n)). - Karl-Heinz Hofmann, Jun 16 2025

Extensions

Additional references and comments from Len Smiley, Joshua Zucker, Rick L. Shepherd and Herbert S. Wilf
Typo in definition corrected by Reinhard Zumkeller, Aug 23 2011
Incorrect formula deleted and text edited by Johannes W. Meijer, Feb 07 2013

A016825 Positive integers congruent to 2 (mod 4): a(n) = 4*n+2, for n >= 0.

Original entry on oeis.org

2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, 146, 150, 154, 158, 162, 166, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234
Offset: 0

Views

Author

Keywords

Comments

Twice the odd numbers, also called singly even numbers.
Numbers having equal numbers of odd and even divisors: A001227(a(n)) = A000005(2*a(n)). - Reinhard Zumkeller, Dec 28 2003
Continued fraction for coth(1/2) = (e+1)/(e-1). The continued fraction for tanh(1/2) = (e-1)/(e+1) would be a(0) = 0, a(n) = A016825(n-1), n >= 1.
No solutions to a(n) = b^2 - c^2. - Henry Bottomley, Jan 13 2001
Sequence gives m such that 8 is the largest power of 2 dividing A003629(k)^m-1 for any k. - Benoit Cloitre, Apr 05 2002
k such that Sum_{d|k} (-1)^d = A048272(k) = 0. - Benoit Cloitre, Apr 15 2002
Also k such that Sum_{d|k} phi(d)*mu(k/d) = A007431(k) = 0. - Benoit Cloitre, Apr 15 2002
Also k such that Sum_{d|k} (d/A000005(d))*mu(k/d) = 0, k such that Sum_{d|k}(A000005(d)/d)*mu(k/d) = 0. - Benoit Cloitre, Apr 19 2002
Solutions to phi(x) = phi(x/2); primorial numbers are here. - Labos Elemer, Dec 16 2002
Together with 1, numbers that are not the leg of a primitive Pythagorean triangle. - Lekraj Beedassy, Nov 25 2003
For n > 0: complement of A107750 and A023416(a(n)-1) = A023416(a(n)) <> A023416(a(n)+1). - Reinhard Zumkeller, May 23 2005
Also the minimal value of Sum_{i=1..n+2} (p(i) - p(i+1))^2, where p(n+3) = p(1), as p ranges over all permutations of {1,2,...,n+2} (see the Mihai reference). Example: a(2)=10 because the values of the sum for the permutations of {1,2,3,4} are 10 (8 times), 12 (8 times) and 18 (8 times). - Emeric Deutsch, Jul 30 2005
Except for a(n)=2, numbers having 4 as an anti-divisor. - Alexandre Wajnberg, Oct 02 2005
A139391(a(n)) = A006370(a(n)) = A005408(n). - Reinhard Zumkeller, Apr 17 2008
Also a(n) = (n-1) + n + (n+1) + (n+2), so a(n) and -a(n) are all the integers that are sums of four consecutive integers. - Rick L. Shepherd, Mar 21 2009
The denominator in Pi/8 = 1/2 - 1/6 + 1/10 - 1/14 + 1/18 - 1/22 + .... - Mohammad K. Azarian, Oct 13 2011
This sequence gives the positive zeros of i^x + 1 = 0, x real, where i^x = exp(i*x*Pi/2). - Ilya Gutkovskiy, Aug 08 2015
Numbers k such that Sum_{j=1..k} j^3 is not a multiple of k. - Chai Wah Wu, Aug 23 2017
Numbers k such that Lucas(k) is a multiple of 3. - Bruno Berselli, Oct 17 2017
Also numbers k such that t^k == -1 (mod 5), where t is a term of A047221. - Bruno Berselli, Dec 28 2017
The even numbers form a ring, and these are the primes in that ring. Note that unique factorization into primes does not hold, since 60 = 2*30 = 6*10. - N. J. A. Sloane, Nov 11 2019
Also numbers ending with 10 in base 2. - John Keith, May 09 2022

Examples

			0.4621171572600097585023184... = 0 + 1/(2 + 1/(6 + 1/(10 + 1/(14 + ...)))), i.e., c.f. for tanh(1/2).
2.1639534137386528487700040... = 2 + 1/(6 + 1/(10 + 1/(14 + 1/(18 + ...)))), i.e., c.f. for coth(1/2).
		

References

  • H. Bass, Mathematics, Mathematicians and Mathematics Education, Bull. Amer. Math. Soc. (N.S.) 42 (2004), no. 4, 417-430.
  • Arthur Beiser, Concepts of Modern Physics, 2nd Ed., McGraw-Hill, 1973.
  • J. R. Goldman, The Queen of Mathematics, 1998, p. 70.
  • Granino A. Korn and Theresa M. Korn, Mathematical Handbook for Scientists and Engineers, McGraw-Hill Book Company, New York (1968).
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, pages 262, 278.

Crossrefs

First differences of A001105.
Cf. A160327 (decimal expansion).
Subsequence of A042963.
Essentially the complement of A042965.

Programs

Formula

a(n) = 4*n + 2, for n >= 0.
a(n) = 2*A005408(n). - Lekraj Beedassy, Nov 28 2003
a(n) = A118413(n+1,2) for n>1. - Reinhard Zumkeller, Apr 27 2006
From Michael Somos, Apr 11 2007: (Start)
G.f.: 2*(1+x)/(1-x)^2.
E.g.f.: 2*(1+2*x)*exp(x).
a(n) = a(n-1) + 4.
a(-1-n) = -a(n). (End)
a(n) = 8*n - a(n-1) for n > 0, a(0)=2. - Vincenzo Librandi, Nov 20 2010
From Reinhard Zumkeller, Jun 11 2012, Jun 30 2012 and Jul 20 2012: (Start)
A080736(a(n)) = 0.
A007814(a(n)) = 1;
A037227(a(n)) = 3.
A214546(a(n)) = 0. (End)
a(n) = T(n+2) - T(n-2) where T(n) = n*(n+1)/2 = A000217(n). In general, if M(k,n) = 2*k*n + k, then M(k,n) = T(n+k) - T(n-k). - Charlie Marion, Feb 24 2020
From Amiram Eldar, Nov 22 2024: (Start)
Product_{n>=1} (1 - (-1)^n/a(n)) = 1/sqrt(2-sqrt(2)) (A285871).
Product_{n>=1} (1 + (-1)^n/a(n)) = sqrt(1-1/sqrt(2)) (A154739). (End)

A017113 a(n) = 8*n + 4.

Original entry on oeis.org

4, 12, 20, 28, 36, 44, 52, 60, 68, 76, 84, 92, 100, 108, 116, 124, 132, 140, 148, 156, 164, 172, 180, 188, 196, 204, 212, 220, 228, 236, 244, 252, 260, 268, 276, 284, 292, 300, 308, 316, 324, 332, 340, 348, 356, 364, 372, 380, 388, 396, 404, 412, 420, 428, 436, 444, 452, 460, 468
Offset: 0

Views

Author

Keywords

Comments

Apart from initial term(s), dimension of the space of weight 2n cuspidal newforms for Gamma_0(65).
n such that 16 is the largest power of 2 dividing A003629(k)^n - 1 for any k. - Benoit Cloitre, Mar 23 2002
Continued fraction expansion of tanh(1/4). - Benoit Cloitre, Dec 17 2002
Consider all primitive Pythagorean triples (a,b,c) with c - a = 8, sequence gives values for b. (Corresponding values for a are A078371(n), while c follows A078370(n).) - Lambert Klasen (Lambert.Klasen(AT)gmx.net), Nov 19 2004
Also numbers of the form a^2 + b^2 + c^2 + d^2, where a,b,c,d are odd integers. - Alexander Adamchuk, Dec 01 2006
If X is an n-set and Y_i (i=1,2,3) mutually disjoint 2-subsets of X then a(n-5) is equal to the number of 4-subsets of X intersecting each Y_i (i=1,2,3). - Milan Janjic, Aug 26 2007
A007814(a(n)) = 2; A037227(a(n)) = 5. - Reinhard Zumkeller, Jun 30 2012
Numbers k such that 3^k + 1 is divisible by 41. - Bruno Berselli, Aug 22 2018
Lexicographically smallest arithmetic progression of positive integers avoiding Fibonacci numbers. - Paolo Xausa, May 08 2023
From Martin Renner, May 24 2024: (Start)
Also number of points in a grid cross with equally long arms and a width of two points, e.g.:
* *
* * * *
* * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * *
* * * * * *
* * * *
* *
etc. (End)

Crossrefs

First differences of A016742 (even squares).
Cf. A078370, A078371, A081770 (subsequence).

Programs

Formula

a(n) = A118413(n+1,3) for n > 2. - Reinhard Zumkeller, Apr 27 2006
a(n) = Sum_{k=0..4*n} (i^k+1)*(i^(4*n-k)+1), where i = sqrt(-1). - Bruno Berselli, Mar 19 2012
a(n) = 4*A005408(n). - Omar E. Pol, Apr 17 2016
E.g.f.: (8*x + 4)*exp(x). - G. C. Greubel, Apr 26 2018
G.f.: 4*(1+x)/(1-x)^2. - Wolfdieter Lang, Oct 27 2020
Sum_{n>=0} (-1)^n/a(n) = Pi/16 (A019683). - Amiram Eldar, Dec 11 2021
From Amiram Eldar, Nov 22 2024: (Start)
Product_{n>=0} (1 - (-1)^n/a(n)) = sqrt(2) * sin(3*Pi/16).
Product_{n>=0} (1 + (-1)^n/a(n)) = sqrt(2) * cos(3*Pi/16). (End)
a(n) = 2*A016825(n) = A008586(2*n+1). - Elmo R. Oliveira, Apr 10 2025

A220466 a((2*n-1)*2^p) = 4^p*(n-1) + 2^(p-1)*(1+2^p), p >= 0 and n >= 1.

Original entry on oeis.org

1, 3, 2, 10, 3, 7, 4, 36, 5, 11, 6, 26, 7, 15, 8, 136, 9, 19, 10, 42, 11, 23, 12, 100, 13, 27, 14, 58, 15, 31, 16, 528, 17, 35, 18, 74, 19, 39, 20, 164, 21, 43, 22, 90, 23, 47, 24, 392, 25, 51, 26, 106, 27, 55, 28, 228, 29, 59, 30, 122, 31, 63, 32, 2080, 33, 67, 34, 138, 35
Offset: 1

Views

Author

Johannes W. Meijer, Dec 24 2012

Keywords

Comments

The a(n) appeared in the analysis of A220002, a sequence related to the Catalan numbers.
The first Maple program makes use of a program by Peter Luschny for the calculation of the a(n) values. The second Maple program shows that this sequence has a beautiful internal structure, see the first formula, while the third Maple program makes optimal use of this internal structure for the fast calculation of a(n) values for large n.
The cross references lead to sequences that have the same internal structure as this sequence.

Crossrefs

Cf. A000027 (the natural numbers), A000120 (1's-counting sequence), A000265 (remove 2's from n), A001316 (Gould's sequence), A001511 (the ruler function), A003484 (Hurwitz-Radon numbers), A003602 (a fractal sequence), A006519 (highest power of 2 dividing n), A007814 (binary carry sequence), A010060 (Thue-Morse sequence), A014577 (dragon curve), A014707 (dragon curve), A025480 (nim-values), A026741, A035263 (first Feigenbaum symbolic sequence), A037227, A038712, A048460, A048896, A051176, A053381 (smooth nowhere-zero vector fields), A055975 (Gray code related), A059134, A060789, A060819, A065916, A082392, A085296, A086799, A088837, A089265, A090739, A091512, A091519, A096268, A100892, A103391, A105321 (a fractal sequence), A109168 (a continued fraction), A117973, A129760, A151930, A153733, A160467, A162728, A181988, A182241, A191488 (a companion to Gould's sequence), A193365, A220466 (this sequence).

Programs

  • Haskell
    -- Following Ralf Stephan's recurrence:
    import Data.List (transpose)
    a220466 n = a006519_list !! (n-1)
    a220466_list = 1 : concat
       (transpose [zipWith (-) (map (* 4) a220466_list) a006519_list, [2..]])
    -- Reinhard Zumkeller, Aug 31 2014
  • Maple
    # First Maple program
    a := n -> 2^padic[ordp](n, 2)*(n+1)/2 : seq(a(n), n=1..69); # Peter Luschny, Dec 24 2012
    # Second Maple program
    nmax:=69: for p from 0 to ceil(simplify(log[2](nmax))) do for n from 1 to ceil(nmax/(p+2)) do a((2*n-1)*2^p) := 4^p*(n-1)  + 2^(p-1)*(1+2^p) od: od: seq(a(n), n=1..nmax);
    # Third Maple program
    nmax:=69: for p from 0 to ceil(simplify(log[2](nmax))) do n:=2^p: n1:=1: while n <= nmax do a(n) := 4^p*(n1-1)+2^(p-1)*(1+2^p): n:=n+2^(p+1): n1:= n1+1: od: od:  seq(a(n), n=1..nmax);
  • Mathematica
    A220466 = Module[{n, p}, p = IntegerExponent[#, 2]; n = (#/2^p + 1)/2; 4^p*(n - 1) + 2^(p - 1)*(1 + 2^p)] &; Array[A220466, 50] (* JungHwan Min, Aug 22 2016 *)
  • PARI
    a(n)=if(n%2,n\2+1,4*a(n/2)-2^valuation(n/2,2)) \\ Ralf Stephan, Dec 17 2013
    

Formula

a((2*n-1)*2^p) = 4^p*(n-1) + 2^(p-1)*(1+2^p), p >= 0 and n >= 1. Observe that a(2^p) = A007582(p).
a(n) = ((n+1)/2)*(A060818(n)/A060818(n-1))
a(n) = (-1/64)*(q(n+1)/q(n))/(2*n+1) with q(n) = (-1)^(n+1)*2^(4*n-5)*(2*n)!*A060818(n-1) or q(n) = (1/8)*A220002(n-1)*1/(A098597(2*n-1)/A046161(2*n))*1/(A008991(n-1)/A008992(n-1))
Recurrence: a(2n) = 4a(n) - 2^A007814(n), a(2n+1) = n+1. - Ralf Stephan, Dec 17 2013

A051062 a(n) = 16*n + 8.

Original entry on oeis.org

8, 24, 40, 56, 72, 88, 104, 120, 136, 152, 168, 184, 200, 216, 232, 248, 264, 280, 296, 312, 328, 344, 360, 376, 392, 408, 424, 440, 456, 472, 488, 504, 520, 536, 552, 568, 584, 600, 616, 632, 648, 664, 680, 696, 712, 728, 744, 760, 776, 792, 808, 824, 840
Offset: 0

Views

Author

Keywords

Comments

Apart from initial term(s), dimension of the space of weight 2n cuspidal newforms for Gamma_0(97).
n such that 32 is the largest power of 2 dividing A003629(k)^n-1 for any k. - Benoit Cloitre, Mar 23 2002
Continued fraction expansion of tanh(1/8). - Benoit Cloitre, Dec 17 2002
If Y and Z are 2-blocks of a (4n+1)-set X then a(n-1) is the number of 3-subsets of X intersecting both Y and Z. - Milan Janjic, Oct 28 2007
General form: (q*n+x)*q x=+1; q=2=A016825, q=3=A017197, q=4=A119413, ... x=-1; q=3=A017233, q=4=A098502, ... x=+2; q=4=A051062, ... - Vladimir Joseph Stephan Orlovsky, Feb 16 2009
a(n)*n+1 = (4n+1)^2 and a(n)*(n+1)+1 = (4n+3)^2 are both perfect squares. - Carmine Suriano, Jun 01 2014
For all positive integers n, there are infinitely many positive integers k such that k*n + 1 and k*(n+1) + 1 are both perfect squares. Except for 8, all the numbers of this sequence are the smallest integers k which are solutions for getting two perfect squares. Example: a(1) = 24 and 24 * 1 + 1 = 25 = 5^2, then 24 * (1+1) + 1 = 49 = 7^2. [Reference AMM] - Bernard Schott, Sep 24 2017
Numbers k such that 3^k + 1 is divisible by 17*193. - Bruno Berselli, Aug 22 2018

References

  • Letter from Gary W. Adamson concerning Prouhet-Thue-Morse sequence, Nov 11 1999.

Crossrefs

Programs

Formula

a(n) = A118413(n+1,4) for n>3. - Reinhard Zumkeller, Apr 27 2006
a(n) = 32*n - a(n-1) for n>0, a(0)=8. - Vincenzo Librandi, Aug 06 2010
A003484(a(n)) = 8; A209675(a(n)) = 9. - Reinhard Zumkeller, Mar 11 2012
A007814(a(n)) = 3; A037227(a(n)) = 7. - Reinhard Zumkeller, Jun 30 2012
a(-1 - n) = - a(n). - Michael Somos, Jun 02 2014
Sum_{n>=0} (-1)^n/a(n) = Pi/32 (A244978). - Amiram Eldar, Feb 28 2023
From Elmo R. Oliveira, Apr 16 2024: (Start)
G.f.: 8*(1+x)/(1-x)^2.
E.g.f.: 8*exp(x)*(1 + 2*x).
a(n) = 8*A005408(n) = A008598(n) + 8 = A139098(n+1) - A139098(n).
a(n) = 4*A016825(n) = 2*A017113(n) = 2*a(n-1) - a(n-2) for n >= 2. (End)
From Amiram Eldar, Nov 25 2024: (Start)
Product_{n>=0} (1 - (-1)^n/a(n)) = sqrt(2)*sin(7*Pi/32).
Product_{n>=0} (1 + (-1)^n/a(n)) = sqrt(2)*cos(7*Pi/32). (End)

A287729 The c-fusc function c(n) = a(n): a(1)=1, a(2n) = s(n), a(2n+1) = s(n)+s(n+1), where s(n) = A287730(n).

Original entry on oeis.org

1, 0, 1, 1, 2, 1, 1, 0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 5, 2, 5, 3, 4, 1, 3, 2, 3, 1, 2, 1, 1, 0, 1, 1, 2, 1, 3, 2, 3, 1, 4, 3, 5, 2, 5, 3, 4, 1, 5, 4, 7, 3, 8, 5, 7, 2, 7, 5, 8, 3, 7, 4, 5, 1, 6, 5, 9, 4, 11, 7, 10, 3, 11, 8, 13, 5, 12, 7, 9, 2, 9, 7, 12, 5, 13, 8, 11, 3, 10, 7, 11, 4, 9, 5, 6, 1, 5, 4, 7, 3
Offset: 1

Views

Author

I. V. Serov, May 30 2017

Keywords

Comments

Define a sequence chf(n) of Christoffel words over an alphabet {-,+}:
chf(1) = '-',
chf(2*n+0) = negate(chf(n)),
chf(2*n+1) = negate(concatenate(chf(n),chf(n+1))).
Then the length of the chf(n) word is fusc(n) = A002487(n), the number of '-'-signs in the chf(n) word is c-fusc(n) = a(n) (the current sequence) and the number of '+'-signs in the chf(n) word is s-fusc(n) = A287730(n). See examples below.

Examples

			A000027(n) chf(n) A070939(n) A002487(n)    a(n)    A287730(n)
                                fusc       c-fusc     s-fusc
01         '-'       1          1          1          0
02         '+'       2          1          0          1
03         '+-'      2          2          1          1
04         '-'       3          1          1          0
05         '--+'     3          3          2          1
06         '-+'      3          2          1          1
07         '-++'     3          3          1          2
08         '+'       4          1          0          1
09         '+++-'    4          4          1          3
10         '++-'     4          3          1          2
11         '++-+-'   4          5          2          3
12         '+-'      4          2          1          1
13         '+-+--'   4          5          3          2
14         '+--'     4          3          2          1
15         '+---'    4          4          3          1
16         '-'       5          1          1          0
17         '----+'   5          5          4          1
		

Crossrefs

Cf. mutual recurrence pair A000360, A284556 and also A213369.

Programs

  • Python
    from sympy.core.cache import cacheit
    @cacheit
    def c(n): return 1 if n==1 else s(n//2) if n%2==0 else s((n - 1)//2) + s((n + 1)//2)
    @cacheit
    def s(n): return 0 if n==1 else c(n//2) if n%2==0 else c((n - 1)//2) + c((n + 1)//2)
    print([c(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 08 2017
  • Scheme
    (definec (A287729 n) (cond ((= 1 n) n) ((even? n) (A287730 (/ n 2))) (else (+ (A287730 (/ (- n 1) 2)) (A287730 (/ (+ n 1) 2))))))
    ;; An implementation of memoization-macro definec can be found for example in: http://oeis.org/wiki/Memoization - Antti Karttunen, Jun 01 2017
    

Formula

The mutual diatomic recurrence pair c(n) (this sequence) and s(n) (A287730) are defined by c(1)=1, s(1)=0, c(2n) = s(n), c(2n+1) = s(n)+s(n+1), s(2n) = c(n), s(2n+1) = c(n)+c(n+1).
a(n) + A287730(n) = A002487(n). [c-fusc(n) + s-fusc(n) = fusc(n).]
gcd(a(n), A287730(n)) = gcd(a(n), A002487(n)) = 1.
Let k(n) = A037227(n) = 1 + 2*A007814(n) = 1 + 2*floor(A002487(n-1)/A002487(n)) for n > 1.
Let d(n) = 2*A255738(n)*(-1)^A070939(n) = 2*(n==2^(A070939(n)-1)+1)*(-1)^A070939(n) = 2*(n==A053644(n)+1)*(-1)^A070939(n) = 2*(A002487(n-1)==1)*(-1)^A070939(n) for n > 1;
then a(n) = k(n-1)*a(n-1) - a(n-2) + d(n) for n > 2 with a(1) = 1, a(2) = 0.
From Yosu Yurramendi, Apr 09 2019: (Start)
For m >= 0, m even, 0 <= k < 2^m, a(2^m+k) = A002487(2^m-k).
For m >= 0, m odd, 0 <= k < 2^m, a(2^m+k) = A002487(k).
(End)

A287730 The s-fusc function s(n) = a(n): a(1) = 0, a(2n) = A287729(n), a(2n+1) = A287729(n) + A287729(n+1).

Original entry on oeis.org

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

Views

Author

I. V. Serov, May 30 2017

Keywords

Comments

Define a sequence chf(n) of Christoffel words over an alphabet {-,+}:
chf(1) = '-',
chf(2*n+0) = negate(chf(n)),
chf(2*n+1) = negate(concatenate(chf(n),chf(n+1))).
Then the length of the chf(n) word is fusc(n) = A002487(n), the number of '-'-signs in the chf(n) word is c-fusc(n) = A287729(n) and the number of '+'-signs in the chf(n) word is the current sequence a(n) = s-fusc(n). See examples below.

Examples

			n         chf(n) A070939(n) A002487(n) A287729(n)    a(n)
                                fusc       c-fusc     s-fusc
1          '-'       1          1          1          0
2          '+'       2          1          0          1
3          '+-'      2          2          1          1
4          '-'       3          1          1          0
5          '--+'     3          3          2          1
6          '-+'      3          2          1          1
7          '-++'     3          3          1          2
8          '+'       4          1          0          1
9          '+++-'    4          4          1          3
10         '++-'     4          3          1          2
11         '++-+-'   4          5          2          3
12         '+-'      4          2          1          1
13         '+-+--'   4          5          3          2
14         '+--'     4          3          2          1
15         '+---'    4          4          3          1
16         '-'       5          1          1          0
17         '----+'   5          5          4          1
		

Crossrefs

Cf. mutual recurrence pair A000360, A284556 and also A213369.

Programs

  • Python
    from sympy.core.cache import cacheit
    @cacheit
    def c(n): return 1 if n==1 else s(n//2) if n%2==0 else s((n - 1)//2) + s((n + 1)//2)
    @cacheit
    def s(n): return 0 if n==1 else c(n//2) if n%2==0 else c((n - 1)//2) + c((n + 1)//2)
    print([s(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 08 2017
  • Scheme
    (definec (A287730 n) (cond ((= 1 n) 0) ((even? n) (A287729 (/ n 2))) (else (+ (A287729 (/ (- n 1) 2)) (A287729 (/ (+ n 1) 2))))))
    ;; An implementation of memoization-macro definec can be found for example in: http://oeis.org/wiki/Memoization
    ;; Second version after the alternative formula given by the author:
    (definec (A287730 n) (if (<= n 2) (- n 1) (- (* (A037227 (- n 1)) (A287730 (- n 1))) (A287730 (- n 2)) (* (if (= 1 (A002487 (- n 1))) 1 0) 2 (expt -1 (A070939 n)))))) ;; Antti Karttunen, Jun 01 2017
    

Formula

The mutual diatomic recurrence pair c(n) (A287729) and s(n) (this sequence) are defined by c(1)=1, s(1)=0, c(2n) = s(n), c(2n+1) = s(n)+s(n+1), s(2n) = c(n), s(2n+1) = c(n)+c(n+1).
a(n) + A287729(n) = A002487(n). [s-fusc(n) + c-fusc(n) = fusc(n).]
gcd(a(n), A287729(n)) = gcd(a(n), A002487(n)) = 1.
Let k(n) = A037227(n) = 1 + 2*A007814(n) = 1 + 2*floor(A002487(n-1)/A002487(n)) for n > 1.
Let d(n) = 2*A255738(n)*(-1)^A070939(n) = 2*(n==2^(A070939(n)-1)+1)*(-1)^A070939(n) = 2*(n==A053644(n)+1)*(-1)^A070939(n) = 2*(A002487(n-1)==1)*(-1)^A070939(n) for n > 1;
then a(n) = k(n-1)*a(n-1) - a(n-2) - d(n) for n > 2 with a(1) = 0, a(2) = 1.

A069517 a(n) = (-1)*Sum_{d|n} (moebius(d)*(-1)^d).

Original entry on oeis.org

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

Views

Author

Benoit Cloitre, Apr 16 2002

Keywords

Comments

From Andrew Howroyd, Jul 25 2018: (Start)
Moebius transform of A037227.
Multiplicative because A037227 is. (End)

Crossrefs

Programs

  • Mathematica
    a[n_] := If[n == 2^IntegerExponent[n, 2], 2, 0]; a[1] = 1; Array[a, 100] (* Amiram Eldar, Aug 29 2023 *)
  • PARI
    A069517(n) = (-1)*sumdiv(n,d,moebius(d)*((-1)^d)); \\ Antti Karttunen, Nov 19 2017
    
  • PARI
    a(n) = if(n == 1, 1, if(n >> valuation(n, 2) == 1, 2, 0)); \\ Amiram Eldar, Aug 29 2023

Formula

a(1) = 1 and for n>1, a(n) = 2*A209229(n). - corrected by Antti Karttunen, Nov 19 2017
Multiplicative with a(2^e) = 2 and a(p^e) = 0 for an odd prime p. - Amiram Eldar, Aug 29 2023
Showing 1-10 of 14 results. Next