A001511 The ruler function: exponent of the highest power of 2 dividing 2n. Equivalently, the 2-adic valuation of 2n.
1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1
Offset: 1
A007913 Squarefree part of n: a(n) is the smallest positive number m such that n/m is a square.
1, 2, 3, 1, 5, 6, 7, 2, 1, 10, 11, 3, 13, 14, 15, 1, 17, 2, 19, 5, 21, 22, 23, 6, 1, 26, 3, 7, 29, 30, 31, 2, 33, 34, 35, 1, 37, 38, 39, 10, 41, 42, 43, 11, 5, 46, 47, 3, 1, 2, 51, 13, 53, 6, 55, 14, 57, 58, 59, 15, 61, 62, 7, 1, 65, 66, 67, 17, 69, 70, 71, 2, 73, 74, 3, 19, 77
Offset: 1
Comments
Also called core(n). [Not to be confused with the squarefree kernel of n, A007947.]
Sequence read mod 4 gives A065882. - Philippe Deléham, Mar 28 2004
This is an arithmetic function and is undefined if n <= 0.
A note on square roots of numbers: we can write sqrt(n) = b*sqrt(c) where c is squarefree. Then b = A000188(n) is the "inner square root" of n, c = A007913(n), lcm(A007947(b),c) = A007947(n) = "squarefree kernel" of n and bc = A019554(n) = "outer square root" of n. [Corrected by M. F. Hasler, Mar 01 2018]
If n > 1, the quantity f(n) = log(n/core(n))/log(n) satisfies 0 <= f(n) <= 1; f(n) = 0 when n is squarefree and f(n) = 1 when n is a perfect square. One can define n as being "epsilon-almost squarefree" if f(n) < epsilon. - Kurt Foster (drsardonicus(AT)earthlink.net), Jun 28 2008
a(n) is the smallest natural number m such that product of geometric mean of the divisors of n and geometric mean of the divisors of m are integers. Geometric mean of the divisors of number n is real number b(n) = Sqrt(n). a(n) = 1 for infinitely many n. a(n) = 1 for numbers from A000290: a(A000290(n)) = 1. For n = 8; b(8) = sqrt(8), a(n) = 2 because b(2) = sqrt(2); sqrt(8) * sqrt(2) = 4 (integer). - Jaroslav Krizek, Apr 26 2010
Dirichlet convolution of A010052 with the sequence of absolute values of A055615. - R. J. Mathar, Feb 11 2011
Booker, Hiary, & Keating outline a method for bounding (on the GRH) a(n) for large n using L-functions. - Charles R Greathouse IV, Feb 01 2013
According to the formula a(n) = n/A000188(n)^2, the scatterplot exhibits the straight lines y=x, y=x/4, y=x/9, ..., i.e., y=x/k^2 for all k=1,2,3,... - M. F. Hasler, May 08 2014
a(n) = 1 if n is a square, a(n) = n if n is a product of distinct primes. - Zak Seidov, Jan 30 2016
All solutions of the Diophantine equation n*x=y^2 or, equivalently, G(n,x)=y, with G being the geometric mean, are of the form x=k^2*a(n), y=k*sqrt(n*a(n)), where k is a positive integer. - Stanislav Sykora, Feb 03 2016
If f is a multiplicative function then Sum_{d divides n} f(a(d)) is also multiplicative. For example, A010052(n) = Sum_{d divides n} mu(a(d)) and A046951(n) = Sum_{d divides n} mu(a(d)^2). - Peter Bala, Jan 24 2024
Links
- Daniel Forgues, Table of n, a(n) for n = 1..100000 (first 1000 terms from T. D. Noe)
- Krassimir T. Atanassov, On Some of Smarandache's Problems.
- Krassimir T. Atanassov, On the 22nd, 23rd, and the 24th Smarandache Problems, Notes on Number Theory and Discrete Mathematics, Sophia, Bulgaria, Vol. 5 (1999), No. 2, 80-82.
- Andrew Booker, Ghaith Hiary, and Jon Keating, Detecting squarefree numbers, CNTA XII (2012).
- Henry Bottomley, Some Smarandache-type multiplicative sequences.
- John M. Campbell, An Integral Representation of Kekulé Numbers, and Double Integrals Related to Smarandache Sequences, arXiv preprint arXiv:1105.3399 [math.GM], 2011.
- Vlad Copil and Laurenţiu Panaitopol, Properties of a sequence generated by positive integers, Bulletin mathématique de la Société des Sciences Mathématiques de Roumanie, Nouvelle Série, Vol. 50 (98), No. 2 (2007), pp. 131-137; alternative link.
- Florentin Smarandache, Only Problems, Not Solutions!, Xiquan Publ., Phoenix-Chicago, 1993.
- Eric Weisstein's World of Mathematics, Squarefree Part.
Crossrefs
Programs
-
Haskell
a007913 n = product $ zipWith (^) (a027748_row n) (map (`mod` 2) $ a124010_row n) -- Reinhard Zumkeller, Jul 06 2012
-
Magma
[ Squarefree(n) : n in [1..256] ]; // N. J. A. Sloane, Dec 23 2006
-
Maple
A007913 := proc(n) local f,a,d; f := ifactors(n)[2] ; a := 1 ; for d in f do if type(op(2,d),'odd') then a := a*op(1,d) ; end if; end do: a; end proc: # R. J. Mathar, Mar 18 2011 # second Maple program: a:= n-> mul(i[1]^irem(i[2], 2), i=ifactors(n)[2]): seq(a(n), n=1..100); # Alois P. Heinz, Jul 20 2015 seq(n / expand(numtheory:-nthpow(n, 2)), n=1..77); # Peter Luschny, Jul 12 2022
-
Mathematica
data = Table[Sqrt[n], {n, 1, 100}]; sp = data /. Sqrt[] -> 1; sfp = data/sp /. Sqrt[x] -> x (* Artur Jasinski, Nov 03 2008 *) Table[Times@@Power@@@({#[[1]],Mod[ #[[2]],2]}&/@FactorInteger[n]),{n,100}] (* Zak Seidov, Apr 08 2009 *) Table[{p, e} = Transpose[FactorInteger[n]]; Times @@ (p^Mod[e, 2]), {n, 100}] (* T. D. Noe, May 20 2013 *) Sqrt[#] /. (c_:1)*a_^(b_:0) -> (c*a^b)^2& /@ Range@100 (* Bill Gosper, Jul 18 2015 *)
-
PARI
a(n)=core(n)
-
Python
from sympy import factorint, prod def A007913(n): return prod(p for p, e in factorint(n).items() if e % 2) # Chai Wah Wu, Feb 03 2015
-
Sage
[squarefree_part(n) for n in (1..77)] # Peter Luschny, Feb 04 2015
Formula
Multiplicative with a(p^k) = p^(k mod 2). - David W. Wilson, Aug 01 2001
a(n) modulo 2 = A035263(n); a(A036554(n)) is even; a(A003159(n)) is odd. - Philippe Deléham, Mar 28 2004
Dirichlet g.f.: zeta(2s)*zeta(s-1)/zeta(2s-2). - R. J. Mathar, Feb 11 2011
a(n) = n/( Sum_{k=1..n} floor(k^2/n)-floor((k^2 -1)/n) )^2. - Anthony Browne, Jun 06 2016
a(n) = rad(n)/a(n/rad(n)), where rad = A007947. This recurrence relation together with a(1) = 1 generate the sequence. - Velin Yanev, Sep 19 2017
From Peter Munn, Nov 18 2019: (Start)
a(k*m) = A059897(a(k), a(m)).
a(n) = n / A008833(n).
(End)
From Amiram Eldar, Mar 14 2021: (Start)
Theorems proven by Copil and Panaitopol (2007):
Lim sup_{n->oo} a(n+1)-a(n) = oo.
Lim inf_{n->oo} a(n+1)-a(n) = -oo.
Sum_{k=1..n} 1/a(k) ~ c*sqrt(n) + O(log(n)), where c = zeta(3/2)/zeta(3) (A090699). (End)
a(n) = A019554(n)^2/n. - Jianing Song, May 08 2022
Sum_{k=1..n} a(k) ~ c * n^2, where c = Pi^2/30 = 0.328986... . - Amiram Eldar, Oct 25 2022
Extensions
More terms from Michael Somos, Nov 24 2001
Definition reformulated by Daniel Forgues, Mar 24 2009
A002162 Decimal expansion of the natural logarithm of 2.
6, 9, 3, 1, 4, 7, 1, 8, 0, 5, 5, 9, 9, 4, 5, 3, 0, 9, 4, 1, 7, 2, 3, 2, 1, 2, 1, 4, 5, 8, 1, 7, 6, 5, 6, 8, 0, 7, 5, 5, 0, 0, 1, 3, 4, 3, 6, 0, 2, 5, 5, 2, 5, 4, 1, 2, 0, 6, 8, 0, 0, 0, 9, 4, 9, 3, 3, 9, 3, 6, 2, 1, 9, 6, 9, 6, 9, 4, 7, 1, 5, 6, 0, 5, 8, 6, 3, 3, 2, 6, 9, 9, 6, 4, 1, 8, 6, 8, 7
Offset: 0
Comments
Newton calculated the first 16 terms of this sequence.
Area bounded by y = tan x, y = cot x, y = 0. - Clark Kimberling, Jun 26 2020
Choose four values independently and uniformly at random from the unit interval [0,1]. Sort them, and label them a,b,c,d from least to greatest (so that a b^2+c^2. - Akiva Weinberger, Dec 02 2024
Define the trihyperboloid to be the intersection of the three solid hyperboloids x^2+y^2-z^2<1, x^2-y^2+z^2<1, and -x^2+y^2+z^2<1. This fits perfectly within the cube [-1,1]^3. Then this is the ratio of the volume of the trihyperboloid to its bounding cube. - Akiva Weinberger, Dec 02 2024
Examples
0.693147180559945309417232121458176568075500134360255254120680009493393...
References
- G. Boros and V. H. Moll, Irresistible Integrals: Symbolics, Analysis and Experiments in the Evaluation of Integrals, Cambridge University Press, 2004.
- Calvin C. Clawson, Mathematical Mysteries: The Beauty and Magic of Numbers, Springer, 2013. See p. 227.
- John H. Conway and Richard K. Guy, The Book of Numbers, New York: Springer-Verlag, 1996. See pp. 24, 250.
- Steven R. Finch, Mathematical Constants, Cambridge, 2003, Sections 1.3.3, 2.21, 6.2, and 7.2.
- 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).
- Jerome Spanier and Keith B. Oldham, "Atlas of Functions", Hemisphere Publishing Corp., 1987, chapter 25 and appendix A, equations 25:14:3 and A:7:3 at pages 232, 670.
- David Wells, The Penguin Dictionary of Curious and Interesting Numbers. Penguin Books, NY, 1986, Revised edition 1987, p. 29.
Links
- Harry J. Smith, Table of n, a(n) for n = 0..20000
- D. H. Bailey and J. M. Borwein, Experimental Mathematics: Examples, Methods and Implications, Notices of the AMS, May 2005, Volume 52, Issue 5.
- Peter Bala, New series for old functions
- J. M. Borwein, P. B. Borwein, and K. Dilcher, Pi, Euler numbers and asymptotic expansions, Amer. Math. Monthly, 96 (1989), 681-687.
- Paul Cooijmans, Odds.
- X. Gourdon and P. Sebah, The logarithm constant:log(2), 2001.
- X. Gourdon and P. Sebah, The logarithm constant:log(2), 2004. (Revised and extended version of above article.)
- M. Kontsevich and D. Zagier, Periods, pp. 4-5.
- Mathematical Reflections, Solution to Problem U376, Issue 4, 2016, p 17.
- Isaac Newton, The method of fluxions and infinite series; with its application to the geometry of curve-lines, 1736; see p. 96.
- Michael Penn, an alternating floor sum., YouTube video, 2020.
- Michael Penn, A wonderful limit from the 2011 Virginia Tech Regional Math Competition, YouTube video, 2022.
- Simon Plouffe, log(2), natural logarithm of 2 to 2000 places.
- S. Ramanujan, Question 260, J. Ind. Math. Soc., III, p. 43.
- Albert Stadler, Problem 3567, Crux Mathematicorum, Vol. 36 (Oct. 2010), p. 396; Oliver Geupel, Solution, Crux Mathematicorum, Vol. 37 (Oct. 2011), pp. 400-401.
- D. W. Sweeney, On the computation of Euler's constant, Math. Comp., 17 (1963), 170-178.
- Horace S. Uhler, Recalculation and extension of the modulus and of the logarithms of 2, 3, 5, 7 and 17, Proc. Nat. Acad. Sci. U. S. A. 26, (1940). 205-212.
- Eric Weisstein's World of Mathematics, Natural Logarithm of 2, Masser-Gramain Constant, Logarithmic Integral, Dirichlet Eta Function.
- Wikipedia, Natural logarithm of 2.
- Wikipedia, Period (algebraic geometry).
- Index entries for transcendental numbers.
Programs
-
Mathematica
RealDigits[N[Log[2],200]][[1]] (* Vladimir Joseph Stephan Orlovsky, Feb 21 2011 *) RealDigits[Log[2],10,120][[1]] (* Harvey P. Dale, Jan 25 2024 *)
-
PARI
{ default(realprecision, 20080); x=10*log(2); for (n=0, 20000, d=floor(x); x=(x-d)*10; write("b002162.txt", n, " ", d)); } \\ Harry J. Smith, Apr 21 2009
Formula
log(2) = Sum_{k>=1} 1/(k*2^k) = Sum_{j>=1} (-1)^(j+1)/j.
log(2) = Integral_{t=0..1} dt/(1+t).
log(2) = (2/3) * (1 + Sum_{k>=1} 2/((4*k)^3-4*k)) (Ramanujan).
log(2) = 4*Sum_{k>=0} (3-2*sqrt(2))^(2*k+1)/(2*k+1) (Y. Luke). - R. J. Mathar, Jul 13 2006
log(2) = 1 - (1/2)*Sum_{k>=1} 1/(k*(2*k+1)). - Jaume Oliver Lafont, Jan 06 2009, Jan 08 2009
log(2) = 4*Sum_{k>=0} 1/((4*k+1)*(4*k+2)*(4*k+3)). - Jaume Oliver Lafont, Jan 08 2009
From Alexander R. Povolotsky, Jul 04 2009: (Start)
log(2) = (1/4)*(3 - Sum_{n>=1} 1/(n*(n+1)*(2*n+1))).
log(2) = (230166911/9240 - Sum_{k>=1} (1/2)^k*(11/k + 10/(k+1) + 9/(k+2) + 8/(k+3) + 7/(k+4) + 6/(k+5) - 6/(k+7) - 7/(k+8) - 8/(k+9) - 9/(k+10) - 10/(k+11)))/35917. (End)
From log(1-x-x^2) at x=1/2, log(2) = (1/2)*Sum_{k>=1} L(k)/(k*2^k), where L(n) is the n-th Lucas number (A000032). - Jaume Oliver Lafont, Oct 24 2009
log(2) = Sum_{k>=1} 1/(cos(k*Pi/3)*k*2^k) (cf. A176900). - Jaume Oliver Lafont, Apr 29 2010
log(2) = (Sum_{n>=1} 1/(n^2*(n+1)^2*(2*n+1)) + 11)/16. - Alexander R. Povolotsky, Jan 13 2011
log(2) = ((Sum_{n>=1} (2*n+1)/(Sum_{k=1..n} k^2)^2)+396)/576. - Alexander R. Povolotsky, Jan 14 2011
From Alexander R. Povolotsky, Dec 16 2008: (Start)
log(2) = 105*(319/44100 - Sum_{n>=1} 1/(2*n*(2*n+1)*(2*n+3)*(2*n+5)*(2*n+7))).
log(2) = 319/420 - (3/2)*Sum_{n>=1} 1/(6*n^2+39*n+63). (End)
log(2) = Sum_{k>=1} A191907(2,k)/k. - Mats Granvik, Jun 19 2011
log(2) = Integral_{x=0..oo} 1/(1 + e^x) dx. - Jean-François Alcover, Mar 21 2013
log(2) = lim_{s->1} zeta(s)*(1-1/2^(s-1)). - Mats Granvik, Jun 18 2013
From Peter Bala, Dec 10 2013: (Start)
log(2) = (1/3)*Sum_{n >= 0} (5*n+4)/( (3*n+1)*(3*n+2)*C(3*n,n) )*(1/2)^n = (1/12)*Sum_{n >= 0} (28*n+17)/( (3*n+1)*(3*n+2)*C(3*n,n) )*(-1/4)^n.
log(2) = (3/16)*Sum_{n >= 0} (14*n+11)/( (4*n+1)*(4*n+3)*C(4*n,2*n) )*(1/4)^n = (1/12)*Sum_{n >= 0} (34*n+25)/( (4*n+1)*(4*n+3)*C(4*n,2*n) )*(-1/18)^n. For more series of this type see the Bala link.
See A142979 for series acceleration formulas for log(2) obtained from the Mercator series log(2) = Sum_{n >= 1} (-1)^(n+1)/n. See A142992 for series for log(2) related to the root lattice C_n. (End)
log(2) = lim_{n->oo} Sum_{k=2^n..2^(n+1)-1} 1/k. - Richard R. Forberg, Aug 16 2014
From Peter Bala, Feb 03 2015: (Start)
log(2) = (2/3)*Sum_{k >= 0} 1/((2*k + 1)*9^k).
Define a pair of integer sequences A(n) = 9^n*(2*n + 1)!/n! and B(n) = A(n)*Sum_{k = 0..n} 1/((2*k + 1)*9^k). Both satisfy the same second-order recurrence equation u(n) = (40*n + 16)*u(n-1) - 36*(2*n - 1)^2*u(n-2). From this observation we obtain the continued fraction expansion log(2) = (2/3)*(1 + 2/(54 - 36*3^2/(96 - 36*5^2/(136 - ... - 36*(2*n - 1)^2/((40*n + 16) - ... ))))). Cf. A002391, A073000 and A105531 for similar expansions. (End)
log(2) = Sum_{n>=1} (Zeta(2*n)-1)/n. - Vaclav Kotesovec, Dec 11 2015
From Peter Bala, Oct 30 2016: (Start)
Asymptotic expansions:
for N even, log(2) - Sum_{k = 1..N/2} (-1)^(k-1)/k ~ (-1)^(N/2)*(1/N - 1/N^2 + 2/N^4 - 16/N^6 + 272/N^8 - ...), where the sequence of unsigned coefficients [1, 1, 2, 16, 272, ...] is A000182 with an extra initial term of 1. See Borwein et al., Theorem 1 (b);
for N odd, log(2) - Sum_{k = 1..(N-1)/2} (-1)^(k-1)/k ~ (-1)^((N-1)/2)*(1/N - 1/N^3 + 5/N^5 - 61/N^7 + 1385/N^9 - ...), by Borwein et al., Lemma 2 with f(x) := 1/(x + 1/2), h := 1/2 and then set x = (N - 1)/2, where the sequence of unsigned coefficients [1, 1, 5, 61, 1385, ...] is A000364. (End)
log(2) = lim_{n->oo} Sum_{k=1..n} sin(1/(n+k)). See Mathematical Reflections link. - Michel Marcus, Jan 07 2017
log(2) = Sum_{n>=1} A006519(n) / ((1 + 2^A006519(n)) * A000265(n) * (1 + A000265(n))). - Nicolas Nagel, Mar 19 2018
From Amiram Eldar, Jul 02 2020: (Start)
Equals Sum_{k>=2} zeta(k)/2^k.
Equals -Sum_{k>=2} log(1 - 1/k^2).
Equals Sum_{k>=1} 1/A002939(k).
Equals Integral_{x=0..Pi/3} tan(x) dx. (End)
log(2) = Integral_{x=0..Pi/2} (sec(x) - tan(x)) dx. - Clark Kimberling, Jul 08 2020
From Peter Bala, Nov 14 2020: (Start)
log(2) = Integral_{x = 0..1} (x - 1)/log(x) dx (Boros and Moll, p. 97).
log(2) = (1/2)*Integral_{x = 0..1} (x + 2)*(x - 1)^2/log(x)^2 dx.
log(2) = (1/4)*Integral_{x = 0..1} (x^2 + 3*x + 4)*(x - 1)^3/log(x)^3 dx. (End)
log(2) = 2*arcsinh(sqrt(2)/4) = 2*sqrt(2)*Sum_{n >= 0} (-1)^n*C(2*n,n)/ ((8*n+4)*32^n) = 3*Sum_{n >= 0} (-1)^n/((8*n+4)*(2^n)*C(2*n,n)). - Peter Bala, Jan 14 2022
log(2) = Integral_{x=0..oo} ( e^(-x) * (1-e^(-2x)) * (1-e^(-4x)) * (1-e^(-6x)) ) / ( x * (1-e^(-14x)) ) dx (see Crux Mathematicorum link). - Bernard Schott, Jul 11 2022
From Peter Bala, Oct 22 2023: (Start)
log(2) = 23/32 + 2!^3/16 * Sum_{n >= 1} (-1)^n * (n + 1)/(n*(n + 1)*(n + 2))^2 = 707/1024 - 4!^3/(16^2 * 2!^2) * Sum_{n >= 1} (-1)^n * (n + 2)/(n*(n + 1)*(n + 2)*(n + 3)*(n + 4))^2 = 42611/61440 + 6!^3/(16^3 * 3!^2) * Sum_{n >= 1} (-1)^n * (n + 3)/(n*(n + 1)*(n + 2)*(n + 3)*(n + 4)*(n + 5)*(n + 6))^2.
More generally, it appears that for k >= 0, log(2) = c(k) + (2*k)!^3/(16^k * k!^2) * Sum_{n >= 1} (-1)^(n+k+1) * (n + k)/(n*(n + 1)*...*(n + 2*k))^2 , where c(k) is a rational approximation to log(2). The first few values of c(k) are [0, 23/32, 707/1024, 42611/61440, 38154331/55050240, 76317139/110100480, 26863086823/38755368960, ...].
Let P(n,k) = n*(n + 1)*...*(n + k).
Conjecture: for k >= 0 and r even with r - 1 <= k, the series Sum_{n >= 1} (-1)^n * (d/dn)^r (P(n,k)) / (P(n,k)^2 = A(r,k)*log(2) + B(r,k), where A(r,k) and B(r,k) are both rational numbers. (End)
From Peter Bala, Nov 13 2023: (Start)
log(2) = 5/8 + (1/8)*Sum_{k >= 1} (-1)^(k+1) * (2*k + 1)^2 / ( k*(k + 1) )^4
= 257/384 + (3!^5/2^9)*Sum_{k >= 1} (-1)^(k+1) * (2*k + 1)*(2*k + 3)^2*(2*k + 5) / ( k*(k + 1)*(k + 2)*(k + 3) )^4
= 267515/393216 + (5!^5/2^19)*Sum_{k >= 1} (-1)^(k+1) * (2*k + 1)*(2*k + 3)*(2*k + 5)^2*(2*k + 7)*(2*k + 9) / ( k*(k + 1)*(k + 2)*(k + 3)*(k + 4)*(k + 5) )^4
log(2) = 3/4 - 1/128 * Sum_{k >= 0} (-1/16)^k * (10*k + 12)*binomial(2*k+2,k+1)/ ((k + 1)*(2*k + 3)). The terms of the series are O(1/(k^(3/2)*4^n)). (End)
log(2) = eta(1) is a period, where eta(x) is the Dirichlet eta function. - Andrea Pinos, Mar 19 2024
log(2) = K_{n>=0} (n^2 + [n=0])/1, where K is the Gauss notation for an infinite continued fraction. In the expanded form, log(2) = 1/(1 + 1/(1 + 4/(1 + 9/1 + 16/(1 + 25/(1 + ... (see Clawson at p. 227). - Stefano Spezia, Jul 01 2024
log(2) = lim_{n->oo} Sum_{k=1..n} 1/(n + k) = lim_{x->0} (2^x - 1)/x = lim_{x->0} (2^x - 2^(-x))/(2*x) (see Finch). - Stefano Spezia, Oct 19 2024
From Colin Linzer, Nov 08 2024: (Start)
log(2) = Integral_{t=0...oo} (1 - tanh(t)) dt.
log(2) = Integral_{t=0...1} arctanh(t) dt.
log(2) = (1/2) * Integral_{t=-1...1} |arctanh(t)| dt. (End)
log(2) = 1 + Sum_{n >= 1} (-1)^n/(n*(4*n^2 - 1)) = 1/2 + (1/2)*Sum_{n >= 1} 1/(n*(4*n^2 - 1)). - Peter Bala, Jan 07 2025
log(2) = Integral_{x=0..1} Integral_{y=0..1} 1/((1 - x*y)*(1 + x)*(1 + y)) dy dx. - Kritsada Moomuang, May 22 2025
A204892 Least k such that n divides s(k)-s(j) for some j in [1,k), where s(k)=prime(k).
2, 3, 3, 4, 4, 5, 7, 5, 5, 6, 6, 7, 10, 7, 7, 8, 8, 9, 13, 9, 9, 10, 16, 10, 16, 10, 10, 11, 11, 12, 19, 12, 20, 12, 12, 13, 22, 13, 13, 14, 14, 15, 24, 15, 15, 16, 25, 16, 26, 16, 16, 17, 29, 17, 30, 17, 17, 18, 18, 19, 31, 19, 32, 19, 19, 20, 33, 20, 20, 21
Offset: 1
Keywords
Comments
Suppose that (s(i)) is a strictly increasing sequence in the set N of positive integers. For i in N, let r(h) be the residue of s(i+h)-s(i) mod n, for h=1,2,...,n+1. There are at most n distinct residues r(h), so that there must exist numbers h and h' such that r(h)=r(h'), where 0<=h
Corollary: for each n, there are infinitely many pairs (j,k) such that n divides s(k)-s(j), and this result holds if s is assumed unbounded, rather than strictly increasing.
Guide to related sequences:
...
s(n)=prime(n), primes
s(n)=prime(n+1), odd primes
s(n)=prime(n+2), primes >=5
s(n)=prime(n)*prime(n+1) product of consecutive primes
s(n)=(prime(n+1)+prime(n+2))/2: averages of odd primes
s(n)=2^(n-1), powers of 2
s(n)=2^n, powers of 2
s(n)=C(n+1,2), triangular numbers
s(n)=n^2, squares
s(n)=(2n-1)^2, odd squares
s(n)=n(3n-1), pentagonal numbers
s(n)=n(2n-1), hexagonal numbers
s(n)=C(2n-2,n-1), central binomial coefficients
s(n)=(1/2)C(2n,n), (1/2)*(central binomial coefficients)
s(n)=n(n+1), oblong numbers
s(n)=n!, factorials
s(n)=n!!, double factorials
s(n)=3^n-2^n
s(n)=Fibonacci(n+1)
s(n)=Fibonacci(2n-1)
s(n)=Fibonacci(2n)
s(n)=Lucas(n)
s(n)=n*(2^(n-1))
s(n)=ceiling[n^2/2]
s(n)=floor[(n+1)^2/2]
Examples
Let s(k)=prime(k). As in A204890, the ordering of differences s(k)-s(j), follows from the arrangement shown here: k...........1..2..3..4..5...6...7...8...9 s(k)........2..3..5..7..11..13..17..19..23 ... s(k)-s(1)......1..3..5..9..11..15..17..21..27 s(k)-s(2).........2..4..8..10..14..16..20..26 s(k)-s(3)............2..6..8...12..14..18..24 s(k)-s(4)...............4..6...10..12..16..22 ... least (k,j) such that 1 divides s(k)-s(j) for some j is (2,1), so a(1)=2. least (k,j) such that 2 divides s(k)-s(j): (3,2), so a(2)=3. least (k,j) such that 3 divides s(k)-s(j): (3,1), so a(3)=3.
Links
- Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
s[n_] := s[n] = Prime[n]; z1 = 400; z2 = 50; Table[s[n], {n, 1, 30}] (* A000040 *) u[m_] := u[m] = Flatten[Table[s[k] - s[j], {k, 2, z1}, {j, 1, k - 1}]][[m]] Table[u[m], {m, 1, z1}] (* A204890 *) v[n_, h_] := v[n, h] = If[IntegerQ[u[h]/n], h, 0] w[n_] := w[n] = Table[v[n, h], {h, 1, z1}] d[n_] := d[n] = First[Delete[w[n], Position[w[n], 0]]] Table[d[n], {n, 1, z2}] (* A204891 *) k[n_] := k[n] = Floor[(3 + Sqrt[8 d[n] - 1])/2] m[n_] := m[n] = Floor[(-1 + Sqrt[8 n - 7])/2] j[n_] := j[n] = d[n] - m[d[n]] (m[d[n]] + 1)/2 Table[k[n], {n, 1, z2}] (* A204892 *) Table[j[n], {n, 1, z2}] (* A204893 *) Table[s[k[n]], {n, 1, z2}] (* A204894 *) Table[s[j[n]], {n, 1, z2}] (* A204895 *) Table[s[k[n]] - s[j[n]], {n, 1, z2}] (* A204896 *) Table[(s[k[n]] - s[j[n]])/n, {n, 1, z2}] (* A204897 *) (* Program 2: generates A204892 and A204893 rapidly *) s = Array[Prime[#] &, 120]; lk = Table[NestWhile[# + 1 &, 1, Min[Table[Mod[s[[#]] - s[[j]], z], {j, 1, # - 1}]] =!= 0 &], {z, 1, Length[s]}] Table[NestWhile[# + 1 &, 1, Mod[s[[lk[[j]]]] - s[[#]], j] =!= 0 &], {j, 1, Length[lk]}] (* Peter J. C. Moses, Jan 27 2012 *)
-
PARI
a(n)=forprime(p=n+2,,forstep(k=p%n,p-1,n,if(isprime(k), return(primepi(p))))) \\ Charles R Greathouse IV, Mar 20 2013
A001316 Gould's sequence: a(n) = Sum_{k=0..n} (binomial(n,k) mod 2); number of odd entries in row n of Pascal's triangle (A007318); a(n) = 2^A000120(n).
1, 2, 2, 4, 2, 4, 4, 8, 2, 4, 4, 8, 4, 8, 8, 16, 2, 4, 4, 8, 4, 8, 8, 16, 4, 8, 8, 16, 8, 16, 16, 32, 2, 4, 4, 8, 4, 8, 8, 16, 4, 8, 8, 16, 8, 16, 16, 32, 4, 8, 8, 16, 8, 16, 16, 32, 8, 16, 16, 32, 16, 32, 32, 64, 2, 4, 4, 8, 4, 8, 8, 16, 4, 8, 8, 16, 8, 16, 16, 32, 4, 8, 8, 16, 8, 16, 16, 32
Offset: 0
Comments
Also called Dress's sequence.
This sequence might be better called Glaisher's sequence, since James Glaisher showed that odd binomial coefficients are counted by 2^A000120(n) in 1899. - Eric Rowland, Mar 17 2017 [However, the name "Gould's sequence" is deeply entrenched in the literature. - N. J. A. Sloane, Mar 17 2017] [Named after the American mathematician Henry Wadsworth Gould (b. 1928). - Amiram Eldar, Jun 19 2021]
All terms are powers of 2. The first occurrence of 2^k is at n = 2^k - 1; e.g., the first occurrence of 16 is at n = 15. - Robert G. Wilson v, Dec 06 2000
a(n) is the highest power of 2 dividing binomial(2n,n) = A000984(n). - Benoit Cloitre, Jan 23 2002
Also number of 1's in n-th row of triangle in A070886. - Hans Havermann, May 26 2002. Equivalently, number of live cells in generation n of a one-dimensional cellular automaton, Rule 90, starting with a single live cell. - Ben Branman, Feb 28 2009. Ditto for Rule 18. - N. J. A. Sloane, Aug 09 2014. This is also the odd-rule cellular automaton defined by OddRule 003 (see Ekhad-Sloane-Zeilberger "Odd-Rule Cellular Automata on the Square Grid" link). - N. J. A. Sloane, Feb 25 2015
Also number of numbers k, 0<=k<=n, such that (k OR n) = n (bitwise logical OR): a(n) = #{k : T(n,k)=n, 0<=k<=n}, where T is defined as in A080098. - Reinhard Zumkeller, Jan 28 2003
To construct the sequence, start with 1 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 2*a(0),2*a(1),...,2*a(2^k-1). - Benoit Cloitre, Jan 30 2003
Also, numerator((2^k)/k!). - Mohammed Bouayoun (mohammed.bouayoun(AT)sanef.com), Mar 03 2004
The odd entries in Pascal's triangle form the Sierpiński Gasket (a fractal). - Amarnath Murthy, Nov 20 2004
Row sums of Sierpiński's Gasket A047999. - Johannes W. Meijer, Jun 05 2011
Fixed point of the morphism "1" -> "1,2", "2" -> "2,4", "4" -> "4,8", ..., "2^k" -> "2^k,2^(k+1)", ... starting with a(0) = 1; 1 -> 12 -> 1224 -> = 12242448 -> 122424482448488(16) -> ... . - Philippe Deléham, Jun 18 2005
a(n) = number of 1's of stage n of the one-dimensional cellular automaton with Rule 90. - Andras Erszegi (erszegi.andras(AT)chello.hu), Apr 01 2006
Or the number of solutions of the equation: A000120(x) + A000120(n-x) = A000120(n). - Vladimir Shevelev, Jul 19 2009
For positive n, a(n) equals the denominator of the permanent of the n X n matrix consisting entirely of (1/2)'s. - John M. Campbell, May 26 2011
Companions to A001316 are A048896, A105321, A117973, A151930 and A191488. They all have the same structure. We observe that for all these sequences a((2*n+1)*2^p-1) = C(p)*A001316(n), p >= 0. If C(p) = 2^p then a(n) = A001316(n), if C(p) = 1 then a(n) = A048896(n), if C(p) = 2^p+2 then a(n) = A105321(n+1), if C(p) = 2^(p+1) then a(n) = A117973(n), if C(p) = 2^p-2 then a(n) = (-1)*A151930(n) and if C(p) = 2^(p+1)+2 then a(n) = A191488(n). Furthermore for all a(2^p - 1) = C(p). - Johannes W. Meijer, Jun 05 2011
a(n) = number of zeros in n-th row of A219463 = number of ones in n-th row of A047999. - Reinhard Zumkeller, Nov 30 2012
This is the Run Length Transform of S(n) = {1,2,4,8,16,...} (cf. A000079). The Run Length Transform of a sequence {S(n), n>=0} is defined to be the sequence {T(n), n>=0} given by T(n) = Product_i S(i), where i runs through the lengths of runs of 1's in the binary expansion of n. E.g., 19 is 10011 in binary, which has two runs of 1's, of lengths 1 and 2. So T(19) = S(1)*S(2). T(0)=1 (the empty product). - N. J. A. Sloane, Sep 05 2014
A105321(n+1) = a(n+1) + a(n). - Reinhard Zumkeller, Nov 14 2014
a(n) = A261363(n,n) = number of distinct terms in row n of A261363 = number of odd terms in row n+1 of A261363. - Reinhard Zumkeller, Aug 16 2015
From Gary W. Adamson, Aug 26 2016: (Start)
A production matrix for the sequence is lim_{k->infinity} M^k, the left-shifted vector of M:
1, 0, 0, 0, 0, ...
2, 0, 0, 0, 0, ...
0, 1, 0, 0, 0, ...
0, 2, 0, 0, 0, ...
0, 0, 1, 0, 0, ...
0, 0, 2, 0, 0, ...
0, 0, 0, 1, 0, ...
...
The result is equivalent to the g.f. of Apr 06 2003: Product_{k>=0} (1 + 2*z^(2^k)). (End)
Number of binary palindromes of length n for which the first floor(n/2) symbols are themselves a palindrome (Ji and Wilf 2008). - Jeffrey Shallit, Jun 15 2017
Examples
Has a natural structure as a triangle: 1, 2, 2,4, 2,4,4,8, 2,4,4,8,4,8,8,16, 2,4,4,8,4,8,8,16,4,8,8,16,8,16,16,32, 2,4,4,8,4,8,8,16,4,8,8,16,8,16,16,32,4,8,8,16,8,16,16,32,8,16,16,32,16,32,32,64, ... The rows converge to A117973. From _Omar E. Pol_, Jun 07 2009: (Start) Also, triangle begins: 1; 2,2; 4,2,4,4; 8,2,4,4,8,4,8,8; 16,2,4,4,8,4,8,8,16,4,8,8,16,8,16,16; 32,2,4,4,8,4,8,8,16,4,8,8,16,8,16,16,32,4,8,8,16,8,16,16,32,8,16,16,32,16,32,32; 64,2,4,4,8,4,8,8,16,4,8,8,16,8,16,16,32,4,8,8,16,8,16,16,32,8,16,16,32,16,32,... (End) G.f. = 1 + 2*x + 2*x^2 + 4*x^3 + 2*x^4 + 4*x^5 + 4*x^6 + 8*x^7 + 2*x^8 + ... - _Michael Somos_, Aug 26 2015
References
- Arthur T. Benjamin and Jennifer J. Quinn, Proofs that really count: the art of combinatorial proof, M.A.A., 2003, p. 75ff.
- Steven R. Finch, Mathematical Constants, Cambridge, 2003, pp. 145-151.
- James W. L. Glaisher, On the residue of a binomial-theorem coefficient with respect to a prime modulus, Quarterly Journal of Pure and Applied Mathematics, Vol. 30 (1899), pp. 150-156.
- H. W. Gould, Exponential Binomial Coefficient Series. Tech. Rep. 4, Math. Dept., West Virginia Univ., Morgantown, WV, Sep 1961.
- Olivier Martin, Andrew M. Odlyzko, and Stephen Wolfram, Algebraic properties of cellular automata, Comm. Math. Physics, Vol. 93 (1984), pp. 219-258. Reprinted in Theory and Applications of Cellular Automata, S Wolfram, Ed., World Scientific, 1986, pp. 51-90 and in Cellular Automata and Complexity: Collected Papers of Stephen Wolfram, Addison-Wesley, 1994, pp. 71-113
- Manfred R. Schroeder, Fractals, Chaos, Power Laws, W. H. Freeman, NY, 1991, page 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).
- Andrew Wuensche, Exploring Discrete Dynamics, Luniver Press, 2011. See Fig. 2.3.
Links
- Indranil Ghosh, Table of n, a(n) for n = 0..50000 (terms 0..1000 from T. D. Noe)
- David Applegate, Omar E. Pol, and N. J. A. Sloane, The Toothpick Sequence and Other Sequences from Cellular Automata, Congressus Numerantium, Vol. 206 (2010), pp. 157-191. [There is a typo in Theorem 6: (13) should read u(n) = 4.3^(wt(n-1)-1) for n >= 2.]
- Jean-Paul Allouche and Jeffrey Shallit, The ring of k-regular sequences, Theoretical Computer Sci., Vol. 98 (1992), pp. 163-197.
- Paul Barry, A Note on Riordan Arrays with Catalan Halves, arXiv:1912.01124 [math.CO], 2019.
- George Beck and Karl Dilcher, A Matrix Related to Stern Polynomials and the Prouhet-Thue-Morse Sequence, arXiv:2106.10400 [math.CO], 2021.
- Christina Talar Bekaroğlu, Analyzing Dynamics of Larger than Life: Impacts of Rule Parameters on the Evolution of a Bug's Geometry, Master's thesis, Calif. State Univ. Northridge (2023). See pp. 91-92.
- Neil J. Calkin, Eunice Y. S. Chan, and Robert M. Corless, Some Facts and Conjectures about Mandelbrot Polynomials, Maple Transactions (2021) Vol. 1, No. 1, Article 1.
- Neil J. Calkin, Eunice Y. S. Chan, Robert M. Corless, David J. Jeffrey, and Piers W. Lawrence, A Fractal Eigenvector, arXiv:2104.01116 [math.DS], 2021.
- Emeric Deutsch and Bruce E. Sagan, Congruences for Catalan and Motzkin numbers and related sequences, arXiv:math/0407326 [math.CO], 2004.
- Emeric Deutsch and Bruce E. Sagan, Congruences for Catalan and Motzkin numbers and related sequences, J. Num. Theory, Vol. 117 (2006), pp. 191-215.
- Philippe Dumas, Diviser pour régner Comportement asymptotique.
- Philippe Dumas, Diviser pour régner Comportement asymptotique. (has many references)
- Shalosh B. Ekhad, N. J. A. Sloane, and Doron Zeilberger, A Meta-Algorithm for Creating Fast Algorithms for Counting ON Cells in Odd-Rule Cellular Automata, arXiv:1503.01796 [math.CO], 2015; see also the Accompanying Maple Package.
- Shalosh B. Ekhad, N. J. A. Sloane, and Doron Zeilberger, Odd-Rule Cellular Automata on the Square Grid, arXiv:1503.04249 [math.CO], 2015.
- Steven R. Finch, Stolarsky-Harborth Constant. [Broken link]
- Steven R. Finch, Stolarsky-Harborth Constant. [From the Wayback machine]
- Ignas Gasparavičius, Andrius Grigutis, and Juozas Petkelis, Picturesque convolution-like recurrences and partial sums' generation, arXiv:2507.23619 [math.NT], 2025. See p. 28.
- Michael Gilleland, Some Self-Similar Integer Sequences.
- Po-Yi Huang and Wen-Fong Ke, Sequences Derived from The Symmetric Powers of {1, 2, ..., k}, arXiv:2307.07733 [math.CO], 2023.
- Hsien-Kuei Hwang, Svante Janson, and Tsung-Hsi Tsai, Periodic minimum in the count of binomial coefficients not divisible by a prime, arXiv:2408.06817 [math.NT], 2024.
- Kathy Q. Ji and Herbert S. Wilf, Extreme Palindromes, Amer. Math. Monthly, Vol. 115, No. 5 (2008), pp. 447-451.
- Alan J. Macfarlane, Generating functions for integer sequences defined by the evolution of cellular automata....
- Hans Montanus and Ron Westdijk, Cellular Automation and Binomials, Green Blue Mathematics (2022), p. 57.
- Sam Northshield, Stern's Diatomic Sequence 0,1,1,2,1,3,2,3,1,4,..., Amer. Math. Month., Vol. 117, No. 7 (2010), pp. 581-598.
- Tomaz Pisanski and Thomas W. Tucker, Growth in Repeated Truncations of Maps, Atti Sem. Mat. Fis. Univ. Modena, Vol. 49 (2001), suppl., pp. 167-176.
- David G. Poole, The towers and triangles of Professor Claus (or, Pascal knows Hanoi), Math. Mag., Vol. 67, No. 5 (1994), pp. 323-344.
- Joseph M. Shunia, A Polynomial Ring Connecting Central Binomial Coefficients and Gould's Sequence, arXiv:2312.00302 [math.GM], 2023.
- N. J. A. Sloane, Illustration of first 20 generations of Rule 90.
- N. J. A. Sloane, On the Number of ON Cells in Cellular Automata, arXiv:1503.01168 [math.CO], 2015.
- N. J. A. Sloane, Catalog of Toothpick and Cellular Automata Sequences in the OEIS.
- Lukas Spiegelhofer and Michael Wallner, Divisibility of binomial coefficients by powers of two, arXiv:1710.10884 [math.NT], 2017.
- Ralf Stephan, Divide-and-conquer generating functions. I. Elementary sequences, arXiv:math/0307027 [math.CO], 2003.
- Alexander Yu. Vlasov, Modelling reliability of reversible circuits with 2D second-order cellular automata, arXiv:2312.13034 [nlin.CG], 2023. See page 12.
- Eric Weisstein's World of Mathematics, Elementary Cellular Automaton.
- Stephen Wolfram, Statistical mechanics of cellular automata, Rev. Mod. Phys., Vol. 55 (1983), pp. 601-644.
- Stephen Wolfram, Geometry of Binomial Coefficients, Amer. Math. Monthly, Vol. 91, No. 9 (November 1984), pp. 566-571.
- Chai Wah Wu, Sums of products of binomial coefficients mod 2 and run length transforms of sequences, arXiv preprint arXiv:1610.06166 [math.CO], 2016.
- Zhujun Zhang, A Note on Counting Binomial Heaps, ResearchGate (2019).
- Index entries for sequences related to cellular automata
- Index entries for sequences that are fixed points of mappings
- Index entries for sequences computed with run length transform
Crossrefs
Equals left border of triangle A166548. - Gary W. Adamson, Oct 16 2009
For generating functions Product_{k>=0} (1+a*x^(b^k)) for the following values of (a,b) see: (1,2) A000012 and A000027, (1,3) A039966 and A005836, (1,4) A151666 and A000695, (1,5) A151667 and A033042, (2,2) A001316, (2,3) A151668, (2,4) A151669, (2,5) A151670, (3,2) A048883, (3,3) A117940, (3,4) A151665, (3,5) A151671, (4,2) A102376, (4,3) A151672, (4,4) A151673, (4,5) A151674.
This is the numerator of 2^n/n!, while A049606 gives the denominator.
Cf. A051638, A048967, A007318, A094959, A048896, A117973, A008977, A139541, A048883, A102376, A038573, A159913, A000079, A166548, A006047, A089898, A105321, A061142.
If we subtract 1 from the terms we get a pair of essentially identical sequences, A038573 and A159913.
A163000 and A163577 count binomial coefficients with 2-adic valuation 1 and 2. A275012 gives a measure of complexity of these sequences. - Eric Rowland, Mar 15 2017
Programs
-
Haskell
import Data.List (transpose) a001316 = sum . a047999_row -- Reinhard Zumkeller, Nov 24 2012 a001316_list = 1 : zs where zs = 2 : (concat $ transpose [zs, map (* 2) zs]) -- Reinhard Zumkeller, Aug 27 2014, Sep 16 2011 (Sage, Python) from functools import cache @cache def A001316(n): if n <= 1: return n+1 return A001316(n//2) << n%2 print([A001316(n) for n in range(88)]) # Peter Luschny, Nov 19 2012
-
Maple
A001316 := proc(n) local k; add(binomial(n,k) mod 2, k=0..n); end; S:=[1]; S:=[op(S),op(2*s)]; # repeat ad infinitum! a := n -> 2^add(i,i=convert(n,base,2)); # Peter Luschny, Mar 11 2009
-
Mathematica
Table[ Sum[ Mod[ Binomial[n, k], 2], {k, 0, n} ], {n, 0, 100} ] Nest[ Join[#, 2#] &, {1}, 7] (* Robert G. Wilson v, Jan 24 2006 and modified Jul 27 2014 *) Map[Function[Apply[Plus,Flatten[ #1]]], CellularAutomaton[90,{{1},0},100]] (* Produces counts of ON cells. N. J. A. Sloane, Aug 10 2009 *) ArrayPlot[CellularAutomaton[90, {{1}, 0}, 20]] (* Illustration of first 20 generations. - N. J. A. Sloane, Aug 14 2014 *) Table[2^(RealDigits[n - 1, 2][[1]] // Total), {n, 1, 100}] (* Gabriel C. Benamy, Dec 08 2009 *) CoefficientList[Series[Exp[2*x], {x, 0, 100}], x] // Numerator (* Jean-François Alcover, Oct 25 2013 *) Count[#,?OddQ]&/@Table[Binomial[n,k],{n,0,90},{k,0,n}] (* _Harvey P. Dale, Sep 22 2015 *) 2^DigitSum[Range[0, 100], 2] (* Paolo Xausa, Jul 31 2025 *)
-
PARI
{a(n) = if( n<0, 0, numerator(2^n / n!))};
-
PARI
A001316(n)=1<
M. F. Hasler, May 03 2009 -
PARI
a(n)=2^hammingweight(n) \\ Charles R Greathouse IV, Jan 04 2013
-
Python
def A001316(n): return 2**bin(n)[2:].count("1") # Indranil Ghosh, Feb 06 2017
-
Python
def A001316(n): return 1<
Karl-Heinz Hofmann, Aug 01 2025 -
Python
import numpy # (version >= 2.0.0) n_up_to = 2**22 A000079 = 1 << numpy.arange(n_up_to.bit_length()) A001316 = A000079[numpy.bitwise_count(numpy.arange(n_up_to))] print(A001316[0:100]) # Karl-Heinz Hofmann, Aug 01 2025
-
Scheme
(define (A001316 n) (let loop ((n n) (z 1)) (cond ((zero? n) z) ((even? n) (loop (/ n 2) z)) (else (loop (/ (- n 1) 2) (* z 2)))))) ;; Antti Karttunen, May 29 2017
Formula
a(n) = 2^A000120(n).
a(0) = 1; for n > 0, write n = 2^i + j where 0 <= j < 2^i; then a(n) = 2*a(j).
a(n) = A038573(n) + 1.
G.f.: Product_{k>=0} (1+2*z^(2^k)). - Ralf Stephan, Apr 06 2003
a(n) = Sum_{i=0..2*n} (binomial(2*n, i) mod 2)*(-1)^i. - Benoit Cloitre, Nov 16 2003
a(n) mod 3 = A001285(n). - Benoit Cloitre, May 09 2004
a(n) = 2^n - 2*Sum_{k=0..n} floor(binomial(n, k)/2). - Paul Barry, Dec 24 2004
a(n) = Product_{k=0..log_2(n)} 2^b(n, k), b(n, k) = coefficient of 2^k in binary expansion of n. - Paul D. Hanna
Sum_{k=0..n-1} a(k) = A006046(n).
a(n) = n/2 + 1/2 + (1/2)*Sum_{k=0..n} (-(-1)^binomial(n,k)). - Stephen Crowley, Mar 21 2007
G.f. for a(n)/A156769(n): (1/2)*z^(1/2)*sinh(2*z^(1/2)). - Johannes W. Meijer, Feb 20 2009
Equals infinite convolution product of [1,2,0,0,0,0,0,0,0] aerated (A000079 - 1) times, i.e., [1,2,0,0,0,0,0,0,0] * [1,0,2,0,0,0,0,0,0] * [1,0,0,0,2,0,0,0,0]. - Mats Granvik, Gary W. Adamson, Oct 02 2009
a(n) = f(n, 1) with f(x, y) = if x = 0 then y otherwise f(floor(x/2), y*(1 + x mod 2)). - Reinhard Zumkeller, Nov 21 2009
a(n) = 2^(number of 1's in binary form of (n-1)). - Gabriel C. Benamy, Dec 08 2009
a((2*n+1)*2^p-1) = (2^p)*a(n), p >= 0. - Johannes W. Meijer, Jun 05 2011
a(n) = A226078(n,1). - Reinhard Zumkeller, May 25 2013
a(n) = lcm(n!, 2^n) / n!. - Daniel Suteu, Apr 28 2017
a(0) = 1, a(2*n) = a(n), a(2*n+1) = 2*a(n). - Daniele Parisse, Feb 15 2024
Extensions
Additional comments from Henry Bottomley, Mar 12 2001
Further comments from N. J. A. Sloane, May 30 2009
A003188 Decimal equivalent of Gray code for n.
0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8, 24, 25, 27, 26, 30, 31, 29, 28, 20, 21, 23, 22, 18, 19, 17, 16, 48, 49, 51, 50, 54, 55, 53, 52, 60, 61, 63, 62, 58, 59, 57, 56, 40, 41, 43, 42, 46, 47, 45, 44, 36, 37, 39, 38, 34, 35, 33, 32, 96, 97, 99, 98, 102, 103, 101
Offset: 0
Comments
Inverse of sequence A006068 considered as a permutation of the nonnegative integers, i.e., A006068(A003188(n)) = n = A003188(A006068(n)). - Howard A. Landman, Sep 25 2001
Restricts to a permutation of each {2^(i - 1) .. 2^i - 1}. - Jason Kimberley, Apr 02 2012
a(n) mod 2 = floor(((n + 1) mod 4) / 2), see also A021913. - Reinhard Zumkeller, Apr 28 2012
Invented by Emile Baudot (1845-1903), originally called a "cyclic-permuted" code. Gray codes are named after Frank Gray, who patented their use for shaft encoders in 1953. [F. Gray, "Pulse Code Communication", U.S. Patent 2,632,058, March 17, 1953.] - Robert G. Wilson v, Jun 22 2014
For n >= 2, let G_n be the graph whose vertices are labeled as 0,1,...,2^n-1, and two vertices are adjacent if and only if their binary expansions differ in exactly one bit, then a(0),a(1),...,a(2^n-1),a(0) is a Hamilton cycle in G_n. - Jianing Song, Jun 01 2022
Examples
For n = 13, the binary reflected Gray code representation of n is '1011' and 1011_2 = 11_10. So, a(13) = 11. - _Indranil Ghosh_, Jan 23 2017
References
- M. Gardner, Mathematical Games, Sci. Amer. Vol. 227 (No. 2, Feb. 1972), p. 107.
- M. Gardner, Knotted Doughnuts and Other Mathematical Entertainments. Freeman, NY, 1986, p. 15.
- N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).
Links
- Indranil Ghosh, Table of n, a(n) for n = 0..32767 (first 1001 terms from N. J. A. Sloane)
- M. W. Bunder, K. P. Tognetti, and G. E. Wheeler, On binary reflected Gray codes and functions, Discr. Math., 308 (2008), 1690-1700.
- Hsien-Kuei Hwang, S. Janson, and T.-H. Tsai, Exact and asymptotic solutions of the recurrence f(n) = f(floor(n/2)) + f(ceiling(n/2)) + g(n): theory and applications, Preprint 2016.
- Hsien-Kuei Hwang, S. Janson, and T.-H. Tsai, Exact and Asymptotic Solutions of a Divide-and-Conquer Recurrence Dividing at Half: Theory and Applications, ACM Transactions on Algorithms, 13:4 (2017), #47; DOI: 10.1145/3127585.
- Hsien-Kuei Hwang, Svante Janson, and Tsung-Hsi Tsai, Identities and periodic oscillations of divide-and-conquer recurrences splitting at half, arXiv:2210.10968 [cs.DS], 2022, p. 39.
- P. Mathonet, M. Rigo, M. Stipulanti and N. Zénaïdi, On digital sequences associated with Pascal's triangle, arXiv:2201.06636 [math.NT], 2022.
- J. A. Oteo and J. Ros, A Fractal Set from the Binary Reflected Gray Code, J. Phys. A: Math Gen. 38 (2005) 8935-8949.
- Ed Pegg, Jr., Sequence Pictures, Math Games column, Dec 08 2003.
- Ed Pegg, Jr., Sequence Pictures, Math Games column, Dec 08 2003 [Cached copy, with permission (pdf only)]
- Ralf Stephan, Some divide-and-conquer sequences ...
- Ralf Stephan, Table of generating functions
- Paul Tarau, Isomorphic Data Encodings and their Generalization to Hylomorphisms on Hereditarily Finite Data Types
- Pierluigi Vellucci and Alberto Maria Bersani, Ordering of nested square roots of 2 according to Gray code, arXiv:1604.00222 [math.NT], 2016.
- Index entries for sequences that are permutations of the natural numbers
Crossrefs
Programs
-
C
int a(int n) { return n ^ (n>>1); }
-
Haskell
import Data.Bits (xor, shiftR) a003188 n = n `xor` (shiftR n 1) :: Integer -- Reinhard Zumkeller, May 26 2013, Apr 28 2012
-
Magma
// A recursive algorithm N := 10; s := [[]]; for n in [1..N] do for j in [#s..1 by -1] do Append(~s,Append(s[j],1)); Append(~s[j],0); end for; end for; [SequenceToInteger(b,2):b in s]; // Jason Kimberley, Apr 02 2012
-
Magma
// A direct algorithm I2B := func< i | [b eq 1: b in IntegerToSequence(i,2)]>; B2I := func< s | SequenceToInteger([b select 1 else 0:b in s],2)>; [B2I(Xor(I2B(i),I2B(i div 2)cat[false])):i in [1..127]]; //Jason Kimberley, Apr 02 2012
-
Maple
with(combinat); graycode(6); # to produce first 64 terms printf(cat(` %.6d`$64), op(map(convert, graycode(6), binary))); lprint(); # to produce binary strings # alternative: read("transforms"): A003188 := proc(n) XORnos(n,floor(n/2)) ; end proc: # R. J. Mathar, Mar 09 2015 # another Maple program: a:= n-> Bits[Xor](n, iquo(n, 2)): seq(a(n), n=0..70); # Alois P. Heinz, Aug 16 2020
-
Mathematica
f[n_] := BitXor[n, Floor[n/2]]; Array[f, 70, 0] (* Robert G. Wilson v, Jun 09 2010 *)
-
PARI
a(n)=bitxor(n,n>>1);
-
PARI
a(n)=sum(k=1,n,(-1)^((k/2^valuation(k,2)-1)/2)*2^valuation(k,2))
-
Python
def A003188(n): return int(bin(n^(n//2))[2:],2) # Indranil Ghosh, Jan 23 2017
-
Python
def A003188(n): return n^ n>>1 # Chai Wah Wu, Jun 29 2022
-
R
maxn <- 63 # by choice a <- 1 for(n in 1:maxn){ a[2*n ] <- 2*a[n] + (n%%2 != 0) a[2*n+1] <- 2*a[n] + (n%%2 == 0)} (a <- c(0,a)) # Yosu Yurramendi, Apr 10 2020 (C#) static uint a(this uint n) => (n >> 1) ^ n; // Frank Hollstein, Mar 12 2021
Formula
a(n) = 2*a(floor(n/2)) + A021913(n - 1). - Henry Bottomley, Apr 05 2001
a(n) = n XOR floor(n/2), where XOR is the binary exclusive OR operator. - Paul D. Hanna, Jun 04 2002
G.f.: (1/(1-x)) * Sum_{k>=0} 2^k*x^2^k/(1 + x^2^(k+1)). - Ralf Stephan, May 06 2003
a(0) = 0, a(2n) = 2a(n) + [n odd], a(2n + 1) = 2a(n) + [n even]. - Ralf Stephan, Oct 20 2003
a(0) = 0, a(n) = 2 a(floor(n/2)) + mod(floor((n + 1)/2), 2).
a(0) = 0, a(n + 1) = a(n) XOR 2^A007814(n) - Jaume Simon Gispert (jaume(AT)nuem.com), Sep 11 2004
Inverse of sequence A006068. - Philippe Deléham, Apr 29 2005
a(n) = a(n-1) XOR A006519(n). - Franklin T. Adams-Watters, Jul 18 2011
From Mikhail Kurkov, Sep 27 2023: (Start)
a(2^m + k) = a(2^m - k - 1) + 2^m for 0 <= k < 2^m, m >= 0.
A000118 Number of ways of writing n as a sum of 4 squares; also theta series of four-dimensional cubic lattice Z^4.
1, 8, 24, 32, 24, 48, 96, 64, 24, 104, 144, 96, 96, 112, 192, 192, 24, 144, 312, 160, 144, 256, 288, 192, 96, 248, 336, 320, 192, 240, 576, 256, 24, 384, 432, 384, 312, 304, 480, 448, 144, 336, 768, 352, 288, 624, 576, 384, 96, 456, 744, 576, 336, 432, 960, 576, 192
Offset: 0
Comments
a^2 + b^2 + c^2 + d^2 is one of Ramanujan's 54 universal quaternary quadratic forms. - Michael Somos, Apr 01 2008
a(n) is also the number of quaternions q = a + bi + cj + dk, where a, b, c, d are integers, such that a^2 + b^2 + c^2 + d^2 = n (i.e., so that n is the norm of q). These are Lipschitz integer quaternions. - Rick L. Shepherd, Mar 27 2009
Number 5 and 35 of the 126 eta-quotients listed in Table 1 of Williams 2012. - Michael Somos, Nov 10 2018
This is the convolution square of A004018. - Pierre Abbat, May 15 2023
Examples
G.f. = 1 + 8*q + 24*q^2 + 32*q^3 + 24*q^4 + 48*q^5 + 96*q^6 + 64*q^7 + 24*q^8 + ... a(1)=8 counts 1 = 1^2 + 0^2 + 0^2 + 0^2 = 0^2 + 1^2 + 0^2 + 0^2 = 0^2 + 0^2 + 1^2 + 0^2 = 0^2 + 0^2 + 0^2 + 1^2 and 4 more sums where 1^2 is replaced by (-1)^2. - _R. J. Mathar_, May 16 2023
References
- J. H. Conway and R. K. Guy, The Book of Numbers, New York: Springer-Verlag, 1996, ch. 8, pp. 231-2.
- J. H. Conway and N. J. A. Sloane, Sphere Packing, Lattices and Groups, Springer-Verlag, p. 108, Eq. (49).
- N. J. Fine, Basic Hypergeometric Series and Applications, Amer. Math. Soc., 1988; p. 78, Eq. (32.28). See also top of p. 94.
- E. Freitag and R. Busam, Funktionentheorie 1, 4. Auflage, Springer, 2006, p. 392.
- G. H. Hardy and E. M. Wright, An Introduction to the Theory of Numbers. 3rd ed., Oxford Univ. Press, 1954, p. 314, Theorem 386.
- Carlos J. Moreno and Samuel S. Wagstaff, Jr., Sums of Squares of integers, Chapman & Hall/CRC, 2006, p. 29.
- S. Ramanujan, Collected Papers, Chap. 20, Cambridge Univ. Press 1927 (Proceedings of the Camb. Phil. Soc., 19 (1917) 11-21).
Links
- N. J. A. Sloane, Table of n, a(n) for n = 0..50000 (first 10000 terms from T. D. Noe)
- George E. Andrews, S. B. Ekhad, and D. Zeilberger A Short Proof of Jacobi's Formula for the Number of Representations of an Integer as a Sum of Four Squares, arXiv:math/9206203 [math.CO], 1992.
- George E. Andrews, S. B. Ekhad, and D. Zeilberger, A Short Proof of Jacobi's Formula for the Number of Representations of an Integer as a sum of Four Squares
- George E. Andrews, Sumit Kumar Jha, and J. López-Bonilla, Sums of Squares, Triangular Numbers, and Divisor Sums, Journal of Integer Sequences, Vol. 26 (2023), Article 23.2.5.
- Michael Ball and Dario Alejandro Alpern, Every positive integer is a sum of four integer squares
- Cristina Ballantine and Mircea Merca, Jacobi's four and eight squares theorems and partitions into distinct parts, Mediterr. J. Math 16 (2009) 26.
- R. T. Bumby, Sums of four squares, in Number theory (New York, 1991-1995), 1-8, Springer, New York, 1996.
- R. T. Bumby, Sums of four squares [Cached copy]
- H. H. Chan and C. Krattenthaler, Recent progress in the study of representations of integers as sums of squares, arXiv:math/0407061 [math.NT], 2004.
- Peter L. Clark, A theorem of Minkowski; the four squares theorem (no date).
- Fern Gossow, Lyndon-like cyclic sieving and Gauss congruence, arXiv:2410.05678 [math.CO], 2024. See p. 26.
- E. Grosswald, Representations of Integers as Sums of an Even Number of Squares, Springer-Verlag, NY, 1985, p. 121.
- M. D. Hirschhorn, A Simple Proof of Jacobi's Four-Square Theorem, Proceedings of the American Mathematical Society, Vol. 101, No. 3 (Nov., 1987), pp. 436-438
- Masao Koike, Modular forms on non-compact arithmetic triangle groups, Unpublished manuscript [Extensively annotated with OEIS A-numbers by N. J. A. Sloane, Feb 14 2021. I wrote 2005 on the first page but the internal evidence suggests 1997.]
- G. Nebe and N. J. A. Sloane, The lattice Z4
- S. C. Milne, Infinite families of exact sums of squares formulas, Jacobi elliptic functions, continued fractions and Schur functions, Ramanujan J., 6 (2002), 7-149.
- Y. Mimura, Almost Universal Quadratic Forms.
- Simon Plouffe, Table of n, a(n) for n=0..105817
- B. K. Spearman and K. S. Williams, The simplest arithmetic proof of Jacobi's four squares theorem, Far East Journal of Mathematical Sciences 2.3 (2000): 433-440.
- Eric van Fossen Conrad, Jacobi's Four Square Theorem
- Min Wang and Zhi-Hong Sun, On the number of representations of n as a linear combination of four triangular numbers II, arXiv:1511.00478 [math.NT], 2015.
- Eric W. Weisstein, Quaternion Norm.
- Wikipedia, Hurwitz quaternion
- K. S. Williams, Fourier series of a class of eta quotients, Int. J. Number Theory 8 (2012), no. 4, 993-1004.
- K. S. Williams, The parents of Jacobi's four squares theorem are unique, Amer. Math. Monthly, 120 (2013), 329-345.
- Index entries for sequences related to sums of squares
Crossrefs
Programs
-
Haskell
a000118 0 = 1 a000118 n = 8 * a046897 n -- Reinhard Zumkeller, Aug 12 2015
-
Julia
# JacobiTheta3 is defined in A000122. A000118List(len) = JacobiTheta3(len, 4) A000118List(57) |> println # Peter Luschny, Mar 12 2018
-
MATLAB
a(n) = 8 * sum(find(mod(n,1:n)==0 & mod(1:n,4))) + (n==0) % David Mellinger, Aug 04 2025
-
Magma
A := Basis( ModularForms( Gamma0(4), 2), 57); A[1] + 8*A[2]; /* Michael Somos, Aug 21 2014 */
-
Maple
(add(q^(m^2),m=-10..10))^4; seq(coeff(%,q,n), n=0..50); # Alternative: A000118list := proc(len) series(JacobiTheta3(0, x)^4, x, len+1); seq(coeff(%, x, j), j=0..len-1) end: A000118list(57); # Peter Luschny, Oct 02 2018
-
Mathematica
Table[SquaresR[4, n], {n, 0, 46}] a[ n_] := SeriesCoefficient[ EllipticTheta[ 3, 0, q]^4, {q, 0, n}]; (* Michael Somos, Jun 12 2014 *) a[ n_] := If[ n < 1, Boole[ n == 0], 8 Sum[ If[ Mod[ d, 4] > 0, d, 0], {d, Divisors @ n }]]; (* Michael Somos, Feb 20 2015 *) QP = QPochhammer; CoefficientList[QP[-q]^8/QP[q^2]^4 + O[q]^60, q] (* Jean-François Alcover, Nov 24 2015 *)
-
PARI
{a(n) = if( n<1, n==0, 8 * sumdiv( n, d, if( d%4, d)))}; /* Michael Somos, Apr 01 2003 */
-
PARI
{a(n) = local(A); if( n<0, 0, A = x * O(x^n); polcoeff( (eta(x^2 + A)^5 / (eta(x + A)^2 * eta(x^4 + A)^2))^4, n))}; /* Michael Somos, Apr 01 2008 */
-
PARI
q='q+O('q^66); Vec((eta(q^2)^5/(eta(q)^2*eta(q^4)^2))^4) /* Joerg Arndt, Apr 08 2013 */
-
PARI
a(n) = 8*sigma(n) - if (n % 4, 0, 32*sigma(n/4)); \\ Michel Marcus, Jul 13 2016
-
Python
from sympy import divisors def a(n): return 1 if n==0 else 8*sum(d for d in divisors(n) if d%4 != 0) print([a(n) for n in range(57)]) # Michael S. Branicky, Jan 08 2021
-
Python
from sympy import divisor_sigma def A000118(n): return 1 if n == 0 else 8*divisor_sigma(n) if n % 2 else 24*divisor_sigma(int(bin(n)[2:].rstrip('0'),2)) # Chai Wah Wu, Jun 27 2022
-
Sage
A = ModularForms( Gamma0(4), 2, prec=57) . basis(); A[0] + 8*A[1]; # Michael Somos, Jun 12 2014
-
Sage
Q = DiagonalQuadraticForm(ZZ, [1]*4) Q.representation_number_list(60) # Peter Luschny, Jun 20 2014
Formula
G.f.: theta_3(q)^4 = (Product_{n>=1} (1-q^(2n))*(1+q^(2n-1))^2)^4 = eta(-q)^8/eta(q^2)^4; eta = Dedekind's function.
a(n) = 8*sigma(n) - 32*sigma(n/4) for n > 0, where the latter term is 0 if n is not a multiple of 4.
Euler transform of period 4 sequence [8, -12, 8, -4, ...]. - Michael Somos, Dec 16 2002
G.f. A(x) satisfies 0 = f(A(x), A(x^3), A(x^9)) where f(u, v, w) = v^4 - 30*u*v^2*w + 12*u*v*w*(u + 9*w) - u*w*(u^2 + 9*w*u + 81*w^2). - Michael Somos, Nov 02 2006
G.f. is a period 1 Fourier series which satisfies f(-1/(4*t)) = 4*(t/i)^2*f(t) where q = exp(2*Pi*i*t). - Michael Somos, Jan 25 2008
For n > 0, a(n)/8 is multiplicative and a(p^n)/8 = 1 + p + p^2 + ... + p^n for p an odd prime, a(2^n)/8 = 1 + 2 for n > 0.
G.f.: 1 + 8*Sum_{k>0} x^k / (1 + (-x)^k)^2 = 1 + 8*Sum_{k>0} k * x^k / (1 + (-x)^k).
G.f. = s(2)^20/(s(1)*s(4))^8, where s(k) := subs(q=q^k, eta(q)), where eta(q) is Dedekind's function, cf. A010815. [Fine]
Fine gives another explicit formula for a(n) in terms of the divisors of n.
a(n) = 8*A046897(n), n > 0. - Ralf Stephan, Apr 02 2003
Dirichlet g.f.: Sum_{n>=1} a(n)/n^s = 8*(1-4^(1-s))*zeta(s)*zeta(s-1). [Ramanu. J. 7 (2003) 95-127, eq (3.2)]. - R. J. Mathar, Jul 02 2012
Average value is (Pi^2/2)*n + O(sqrt(n)). - Charles R Greathouse IV, Feb 17 2015
From Wolfdieter Lang, Jan 14 2016: (Start)
For n >= 1: a(n) = 8*Sum_{d | n} b(d)*d, with b(d) = 1 if d/4 is not an integer else 0. See, e.g., the Freitag-Busam reference, p. 392.
For n >= 1: a(n) = 8*sigma(n) if n is odd else 24*sigma(m(n)), where m(n) is the largest odd divisor of n (see A000265), and sigma is given in A000203. See the Moreno-Wagstaff reference, Theorem 2. 6 (Jacobi), p. 29. (End)
a(n) = (8/n)*Sum_{k=1..n} A186690(k)*a(n-k), a(0) = 1. - Seiichi Manyama, May 27 2017
A002326 Multiplicative order of 2 mod 2n+1.
1, 2, 4, 3, 6, 10, 12, 4, 8, 18, 6, 11, 20, 18, 28, 5, 10, 12, 36, 12, 20, 14, 12, 23, 21, 8, 52, 20, 18, 58, 60, 6, 12, 66, 22, 35, 9, 20, 30, 39, 54, 82, 8, 28, 11, 12, 10, 36, 48, 30, 100, 51, 12, 106, 36, 36, 28, 44, 12, 24, 110, 20, 100, 7, 14, 130, 18, 36, 68, 138, 46, 60, 28
Offset: 0
Comments
In other words, least m > 0 such that 2n+1 divides 2^m-1.
Number of riffle shuffles of 2n+2 cards required to return a deck to initial state. A riffle shuffle replaces a list s(1), s(2), ..., s(m) with s(1), s((i/2)+1), s(2), s((i/2)+2), ... a(1) = 2 because a riffle shuffle of [1, 2, 3, 4] requires 2 iterations [1, 2, 3, 4] -> [1, 3, 2, 4] -> [1, 2, 3, 4] to restore the original order.
Concerning the complexity of computing this sequence, see for example Bach and Shallit, p. 115, exercise 8.
It is not difficult to prove that if 2n+1 is a prime then 2n is a multiple of a(n). But the converse is not true. Indeed, one can prove that a(2^(2t-1))=4t. Thus if n=2^(2t-1), where, for any m > 0, t=2^(m-1) then 2n is a multiple of a(n) while 2n+1 is a Fermat number which, as is well known, is not always a prime. It is an interesting problem to describe all composite numbers for which 2n is divisible by a(n). - Vladimir Shevelev, May 09 2008
For an algorithm of calculation of a(n) see author's comment in A179680. - Vladimir Shevelev, Jul 21 2010
From V. Raman, Sep 18 2012, Dec 10 2012: (Start)
If 2n+1 is prime, then the polynomial (x^(2n+1)+1)/(x+1) factors into 2n/a(n) polynomials of the same degree a(n) over GF(2).
If (x^(2n+1)+1)/(x+1) is irreducible over GF(2), then 2n+1 is prime, and 2 is a primitive root (mod 2n+1) (cf. A001122).
For all n > 0, a(n) is the degree of the largest irreducible polynomial factor for the polynomial (x^(2n+1)+1)/(x+1) over GF(2). (End)
a(n) is a factor of phi(2n+1) (A000010(2n+1)). - Douglas Boffey, Oct 21 2013
Conjecture: if p is an odd prime then a((p^3-1)/2) = p * a((p^2-1)/2). Because otherwise a((p^3-1)/2) < p * a((p^2-1)/2) iff a((p^3-1)/2) = a((p-1)/2) for a prime p. Equivalently p^3 divides 2^(p-1)-1, but no such prime p is known. - Thomas Ordowski, Feb 10 2014
A generalization of the previous conjecture: For each k>=2, if p is an odd prime then a(((p^(k+1))-1)/2) = p * a((p^k-1)/2). Computer testing of this generalized conjecture shows that there is no counterexample for k and p both up to 1000. - Ahmad J. Masad, Oct 17 2020
a(n) = a((N-1)/2), with odd N = 2*n+1 >= 3 (n >= 1), is also the primitive period length of (1/N) in binary notation: (1/N)2 = 0.repeat(a[1]a[2]...a[P(N)]), and P(N) = a((N-1)/2). E.g., N = 11 (n = 5), (1/11)_2 = 0.repeat(0001011101), with P(11) = 10 = a(5). Proof: Use a cyclic shift operation sigma (1 step to the left) on the cycle: sigma((1/N)_2) = .repeat(a[2]...a[P(N)]a[1]). Then one can prove for the composition sigma^[k] (k=0 is the identity map) written back in decimal notation the result (sigma^[k]((1/N)_2))_10 = (1/N)*2^k (mod N). E.g. N = 11, sigma^[2]((1/11)_2) = .repeat(0101110100), written in base 10 as 4/11, etc. Hence P(N) and the order of 2 modulo N coincide. - _Gary W. Adamson and Wolfdieter Lang, Oct 14 2020
Examples
From _Vladimir Shevelev_, Oct 03 2017: (Start) Our algorithm for the calculation of a(n) in the author's comment in A179680 (see also the Sage program below) could be represented in the form of a "finite continued fraction". For example let n = 8, 2*n+1 = 17. We have 1 + 17 ------- + 17 2 ------------- + 17 2 ------------------- + 17 2 -------------------------- = 1 32 Here the denominators are the A006519 of the numerators: A006519(1+17) = 2, A006519(9+17) = 2, A006519(13+17) = 2, A006519(15+17) = 32. Summing the exponents of these powers of 2, we obtain the required result: a(8) = 1 + 1 + 1 + 5 = 8. Indeed, we have (((1*32 - 17)*2 - 17)*2 - 17)*2 - 17 = 1. So 32*2*2*2 - 1 == 0 (mod 17), 2^8 - 1 == 0 (mod 17). In the general case, note that all "partial fractions" (which indeed are integers) are odd residues modulo 2*n+1 in the interval [1, 2*n-1]. It is easy to prove that the first 1 appears not later than in the n-th step. (End)
References
- E. Bach and Jeffrey Shallit, Algorithmic Number Theory, I.
- T. Folger, "Shuffling Into Hyperspace," Discover, 1991 (vol 12, no 1), pages 66-67.
- M. Gardner, "Card Shuffles," Mathematical Carnival chapter 10, pages 123-138. New York: Vintage Books, 1977.
- L. Lunelli and M. Lunelli, Tavola di congruenza a^n == 1 mod K per a=2,5,10, Atti Sem. Mat. Fis. Univ. Modena 10 (1960/61), 219-236 (1961).
- J. H. Silverman, A Friendly Introduction to Number Theory, 3rd ed., Pearson Education, Inc, 2006, p. 146, Exer. 21.3
- 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).
Links
- T. D. Noe, Table of n, a(n) for n = 0..10000
- Jean-Paul Allouche, Manon Stipulanti, and Jia-Yan Yao, Doubling modulo odd integers, generalizations, and unexpected occurrences, arXiv:2504.17564 [math.NT], 2025.
- M. Baake, U. Grimm and J. Nilsson, Scaling of the Thue-Morse diffraction measure, arXiv preprint arXiv:1311.4371 [math-ph], 2013.
- D. Bayer and P. Diaconis, Trailing the dovetail shuffle to its lair, Ann. Appl. Prob. 2 (2) (1992) 294-313.
- Matthew Brand, Choosing 1 of N with and without lucky numbers, arXiv:1808.07994 [math.NT], 2018.
- J. Brillhart, J. S. Lomont and P. Morton, Cyclotomic properties of the Rudin-Shapiro polynomials, J. Reine Angew. Math.288 (1976), 37--65. See Table 2. MR0498479 (58 #16589).
- Steve Butler, Persi Diaconis and R. L. Graham, The mathematics of the flip and horseshoe shuffles, arXiv:1412.8533 [math.CO], 2014.
- Steve Butler, Persi Diaconis and R. L. Graham, The mathematics of the flip and horseshoe shuffles, The American Mathematical Monthly 123.6 (2016): 542-556.
- A. J. C. Cunningham, On Binal Fractions, Math. Gaz., 4 (71) (1908), circa p. 266.
- P. Diaconis, R. L. Graham, and W. M. Kantor, The mathematics of perfect shuffles, Adv. Appl. Math. 4 (2) (1983) 175-196
- M. J. Gardner and C. A. McMahan, Riffling casino checks, Math. Mag., 50 (1) (1977), 38-41.
- S. W. Golomb, Permutations by cutting and shuffling, SIAM Rev., 3 (1961), 293-297.
- Jonas Kaiser, On the relationship between the Collatz conjecture and Mersenne prime numbers, arXiv preprint arXiv:1608.00862 [math.GM], 2016.
- Torleiv Klove, On covering sets for limited-magnitude errors, Cryptogr. Commun. 8 (3) (2016) 415-433
- V. I. Levenshtein, Conflict-avoiding codes and cyclic triple systems [in Russian], Problemy Peredachi Informatsii, 43 (No. 3, 2007), 39-53.
- V. I. Levenshtein, Conflict-avoiding codes and cyclic triple systems, Problems of Information Transmission, September 2007, Volume 43, Issue 3, pp 199-212 (translated from Russian)
- Yuan-Hsun Lo, Kenneth W. Shum, Wing Shing Wong and Yijin Zhang, Multichannel Conflict-Avoiding Codes of Weights Three and Four, arXiv:2009.11754 [cs.IT], 2020.
- Jarkko Peltomäki and Aleksi Saarela, Standard words and solutions of the word equation X_1^2 ... X_n^2 = (X_1 ... X_n)^2, Journal of Combinatorial Theory, Series A (2021) Vol. 178, 105340. See also arXiv:2004.14657 [cs.FL], 2020.
- Vladimir Shevelev, Gilberto Garcia-Pulgarin, Juan Miguel Velasquez-Soto and John H. Castillo, Overpseudoprimes, and Mersenne and Fermat numbers as primover numbers, arXiv preprint arXiv:1206:0606 [math.NT], 2012.
- Vladimir Shevelev, G. Garcia-Pulgarin, J. M. Velasquez and J. H. Castillo, Overpseudoprimes, and Mersenne and Fermat Numbers as Primover Numbers, J. Integer Seq. 15 (2012) Article 12.7.7.
- Eric Weisstein's World of Mathematics, Riffle Shuffle
- Eric Weisstein's World of Mathematics, In-Shuffle
- Eric Weisstein's World of Mathematics, Out-Shuffle
- Eric Weisstein's World of Mathematics, Multiplicative Order
- Wikipedia, Riffle Shuffle
Crossrefs
Programs
-
GAP
List([0..100],n->OrderMod(2,2*n+1)); # Muniru A Asiru, Feb 01 2019
-
Haskell
import Data.List (findIndex) import Data.Maybe (fromJust) a002326 n = (+ 1) $ fromJust $ findIndex ((== 0) . (`mod` (2 * n + 1))) $ tail a000225_list -- Reinhard Zumkeller, Apr 22 2013
-
Magma
[ 1 ] cat [ Modorder(2, 2*n+1): n in [1..72] ]; // Klaus Brockhaus, Dec 03 2008
-
Maple
a := n -> `if`(n=0, 1, numtheory:-order(2, 2*n+1)): seq(a(n), n=0..72);
-
Mathematica
Table[MultiplicativeOrder[2, 2*n + 1], {n, 0, 100}] (* Robert G. Wilson v, Apr 05 2011 *)
-
PARI
a(n)=if(n<0,0,znorder(Mod(2,2*n+1))) /* Michael Somos, Mar 31 2005 */
-
Python
from sympy import n_order [n_order(2, 2*n+1) for n in range(73)] # Hermann Stamm-Wilbrandt, Jul 27 2021
-
Sage
# From Peter Luschny, Oct 06 2017: (Start) [Mod(2,n).multiplicative_order() for n in (0..145) if gcd(n,2) == 1] # Algorithm from Vladimir Shevelev as described in A179680 and presented in Example. def A002326VS(n): s, m, N = 0, 1, 2*n + 1 while True: k = N + m v = valuation(k, 2) s += v m = k >> v if m == 1: break return s [A002326VS(n) for n in (0..72)] # (End)
Formula
a((3^n-1)/2) = A025192(n). - Vladimir Shevelev, May 09 2008
a((b(n)-1)/2) = n for odd n and even n such that b(n/2) != b(n), where b(n) = A005420(n). - Thomas Ordowski, Jan 11 2014
Note that a(2^n-1) = n+1 and a(2^n) = 2*(n+1). - Thomas Ordowski, Jan 16 2014
Extensions
More terms from David W. Wilson, Jan 13 2000
More terms from Benoit Cloitre, Apr 11 2003
A228351 Triangle read by rows in which row n lists the compositions (ordered partitions) of n (see Comments lines for definition).
1, 2, 1, 1, 3, 1, 2, 2, 1, 1, 1, 1, 4, 1, 3, 2, 2, 1, 1, 2, 3, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 5, 1, 4, 2, 3, 1, 1, 3, 3, 2, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 4, 1, 1, 3, 1, 2, 2, 1, 1, 1, 2, 1, 3, 1, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 6, 1, 5, 2, 4, 1, 1, 4
Offset: 1
Comments
The representation of the compositions (for fixed n) is as lists of parts, the order between individual compositions (for the same n) is (list-)reversed co-lexicographic. - Joerg Arndt, Sep 02 2013
Dropping the "(list-)reversed" in the comment above gives A228525.
The equivalent sequence for partitions is A026792.
This sequence lists (without repetitions) all finite compositions, in such a way that, if [P_1, ..., P_r] denotes the composition occupying the n-th position in the list, then (((2*n/2^(P_1)-1)/2^(P_2)-1)/...)/2^(P_r)-1 = 0. - Lorenzo Sauras Altuzarra, Jan 22 2020
The k-th composition in the list is obtained by taking the set of positions of 1's in the reversed binary expansion of k, prepending 0, and taking first differences. Reversing again gives A066099, which is described as the standard ordering. Both sequences define a bijective correspondence between nonnegative integers and integer compositions. - Gus Wiseman, Apr 01 2020
It follows from the previous comment that A000120(k) is the length of the k-th composition that is listed by this sequence (recall that A000120(k) is the number of 1's in the binary expansion of k). - Lorenzo Sauras Altuzarra, Sep 29 2020
Examples
Illustration of initial terms: ----------------------------------- n j Diagram Composition j ----------------------------------- . _ 1 1 |_| 1; . _ _ 2 1 |_ | 2, 2 2 |_|_| 1, 1; . _ _ _ 3 1 |_ | 3, 3 2 |_|_ | 1, 2, 3 3 |_ | | 2, 1, 3 4 |_|_|_| 1, 1, 1; . _ _ _ _ 4 1 |_ | 4, 4 2 |_|_ | 1, 3, 4 3 |_ | | 2, 2, 4 4 |_|_|_ | 1, 1, 2, 4 5 |_ | | 3, 1, 4 6 |_|_ | | 1, 2, 1, 4 7 |_ | | | 2, 1, 1, 4 8 |_|_|_|_| 1, 1, 1, 1; . Triangle begins: [1]; [2],[1,1]; [3],[1,2],[2,1],[1,1,1]; [4],[1,3],[2,2],[1,1,2],[3,1],[1,2,1],[2,1,1],[1,1,1,1]; [5],[1,4],[2,3],[1,1,3],[3,2],[1,2,2],[2,1,2],[1,1,1,2],[4,1],[1,3,1],[2,2,1],[1,1,2,1],[3,1,1],[1,2,1,1],[2,1,1,1],[1,1,1,1,1]; ... For example [1,2] occupies the 5th position in the corresponding list of compositions and indeed (2*5/2^1-1)/2^2-1 = 0. - _Lorenzo Sauras Altuzarra_, Jan 22 2020 12 --binary expansion--> [1,1,0,0] --reverse--> [0,0,1,1] --positions of 1's--> [3,4] --prepend 0--> [0,3,4] --first differences--> [3,1]. - _Lorenzo Sauras Altuzarra_, Sep 29 2020
Links
- Peter Kagey, Table of n, a(n) for n = 1..10000
- Mikhail Kurkov, Comments on A228351
- Index entries for sequences that are related to compositions
Crossrefs
All of the following consider the k-th row to be the k-th composition, ignoring the coarser grouping by sum.
- Indices of weakly increasing rows are A114994.
- Indices of weakly decreasing rows are A225620.
- Indices of strictly decreasing rows are A333255.
- Indices of strictly increasing rows are A333256.
- Indices of reversed interval rows A164894.
- Indices of interval rows are A246534.
- Indices of strict rows are A233564.
- Indices of constant rows are A272919.
- Indices of anti-run rows are A333489.
- Row k has Heinz number A333219(k).
Cf. A000120, A029931, A035327, A070939, A233249, A333217, A333218, A333220, A333227, A333627, A333628.
Equals A163510+1, termwise.
Cf. A124734 (increasing length, then lexicographic).
Cf. A296774 (increasing length, then reverse lexicographic).
Cf. A337243 (increasing length, then colexicographic).
Cf. A337259 (increasing length, then reverse colexicographic).
Cf. A296773 (decreasing length, then lexicographic).
Cf. A296772 (decreasing length, then reverse lexicographic).
Cf. A337260 (decreasing length, then colexicographic).
Cf. A108244 (decreasing length, then reverse colexicographic).
Cf. A228369 (lexicographic).
Cf. A066099 (reverse lexicographic).
Cf. A228525 (colexicographic).
Programs
-
Haskell
a228351 n = a228351_list !! (n - 1) a228351_list = concatMap a228351_row [1..] a228351_row 0 = [] a228351_row n = a001511 n : a228351_row (n `div` 2^(a001511 n)) -- Peter Kagey, Jun 27 2016
-
Maple
# Program computing the sequence: A228351 := proc(n) local c, k, L, N: L, N := [], [seq(2*r, r = 1 .. n)]: for k in N do c := 0: while k != 0 do if gcd(k, 2) = 2 then k := k/2: c := c+1: else L := [op(L), op(c)]: k := k-1: c := 0: fi: od: od: L[n]: end: # Lorenzo Sauras Altuzarra, Jan 22 2020 # Program computing the list of compositions: List := proc(n) local c, k, L, M, N: L, M, N := [], [], [seq(2*r, r = 1 .. 2^n-1)]: for k in N do c := 0: while k != 0 do if gcd(k, 2) = 2 then k := k/2: c := c+1: else L := [op(L), c]: k := k-1: c := 0: fi: od: M := [op(M), L]: L := []: od: M: end: # Lorenzo Sauras Altuzarra, Jan 22 2020
-
Mathematica
bpe[n_]:=Join@@Position[Reverse[IntegerDigits[n,2]],1]; Table[Differences[Prepend[bpe[n],0]],{n,0,30}] (* Gus Wiseman, Apr 01 2020 *)
-
Python
from itertools import count, islice def A228351_gen(): # generator of terms for n in count(1): k = n while k: yield (s:=(~k&k-1).bit_length()+1) k >>= s A228351_list = list(islice(A228351_gen(),30)) # Chai Wah Wu, Jul 17 2023
A031443 Digitally balanced numbers: positive numbers that in base 2 have the same number of 0's as 1's.
2, 9, 10, 12, 35, 37, 38, 41, 42, 44, 49, 50, 52, 56, 135, 139, 141, 142, 147, 149, 150, 153, 154, 156, 163, 165, 166, 169, 170, 172, 177, 178, 180, 184, 195, 197, 198, 201, 202, 204, 209, 210, 212, 216, 225, 226, 228, 232, 240, 527, 535, 539, 541, 542, 551
Offset: 1
Comments
Also numbers k such that the binary digital mean dm(2, k) = (Sum_{i=1..d} 2*d_i - 1) / (2*d) = 0, where d is the number of digits in the binary representation of k and d_i the individual digits. - Reikku Kulon, Sep 21 2008
From Reikku Kulon, Sep 29 2008: (Start)
Each run of values begins with 2^(2k + 1) + 2^(k + 1) - 2^k - 1. The initial values increase according to the sequence {2^(k - 1), 2^(k - 2), 2^(k - 3), ..., 2^(k - k)}.
After this, the values follow a periodic sequence of increases by successive powers of two with single odd values interspersed.
Each run ends with an odd increase followed by increases of {2^(k - k), ..., 2^(k - 2), 2^(k - 1), 2^k}, finally reaching 2^(2k + 2) - 2^(k + 1).
Similar behavior occurs in other bases. (End)
A001700 gives number of terms having length 2*n in binary representation: A001700(n-1) = #{m: A070939(a(m))=2*n}. - Reinhard Zumkeller, Jun 08 2011
The number of terms below 2^k is A079309(floor(k/2)) for k > 1. - Amiram Eldar, Nov 21 2020
Examples
9 is a term because '1001' contains 2 '0's and 2 '1's.
Links
- Reikku Kulon, Table of n, a(n) for n = 1..10000
- Jason Bell, Thomas F. Lidbetter and Jeffrey Shallit, Additive number theory via approximation by regular languages, International Journal of Foundations of Computer Science, Vol. 31, No. 6 (2020), pp. 667-687; arXiv preprint, arXiv:1804.07996 [cs.FL], 2018.
- Thomas Finn Lidbetter, Counting, Adding, and Regular Languages, Master's Thesis, University of Waterloo, Ontario, Canada, 2018.
- Reinhard Zumkeller, Haskell Programs for Binary Digitally Balanced Numbers.
- Index entries for sequences related to binary expansion of n
Crossrefs
Programs
-
Haskell
-- See link, showing that Ulrich Schimkes formula provides a very efficient algorithm. Reinhard Zumkeller, Jun 15 2011
-
Magma
[ n: n in [2..250] | Multiplicity({* z: z in Intseq(n,2) *}, 0) eq &+Intseq(n,2) ]; // Bruno Berselli, Jun 07 2011
-
Maple
a:=proc(n) local nn, n1, n0: nn:=convert(n,base,2): n1:=add(nn[i],i=1..nops(nn)): n0:=nops(nn)-n1: if n0=n1 then n else end if end proc: seq(a(n), n = 1..240); # Emeric Deutsch, Jul 31 2008
-
Mathematica
Select[Range[250],DigitCount[#,2,1]==DigitCount[#,2,0]&] (* Harvey P. Dale, Jul 22 2013 *) FromDigits[#,2]&/@DeleteCases[Flatten[Permutations/@Table[PadRight[{},2n,{1,0}],{n,5}],1],?(#[[1]]==0&)]//Sort (* _Harvey P. Dale, May 30 2016 *)
-
PARI
for(n=1,100,b=binary(n); l=length(b); if(sum(i=1,l, component(b,i))==l/2,print1(n,",")))
-
PARI
is(n)=hammingweight(n)==hammingweight(bitneg(n,#binary(n))) \\ Charles R Greathouse IV, Mar 29 2013
-
PARI
is(n)=2*hammingweight(n)==exponent(n)+1 \\ Charles R Greathouse IV, Apr 18 2020
-
Perl
for my $half ( 1 .. 4 ) { my $N = 2 * $half; # only even widths apply my $vector = (1 << ($N-1)) | ((1 << ($N/2-1)) - 1); # first key my $n = 1; $n *= $_ for 2 .. $N; # N! my $d = 1; $d *= $_ for 2 .. $N/2; # (N/2)! for (1 .. $n/($d*$d*2)) { print "$vector, "; my ($v, $d) = ($vector, 0); until ($v & 1 or !$v) { $d = ($d << 1)|1; $v >>= 1 } $vector += $d + 1 + (($v ^ ($v + 1)) >> 2); # next key } } # Ruud H.G. van Tol, Mar 30 2014
-
Python
from sympy.utilities.iterables import multiset_permutations A031443_list = [int('1'+''.join(p),2) for n in range(1,10) for p in multiset_permutations('0'*n+'1'*(n-1))] # Chai Wah Wu, Nov 15 2019
Formula
a(n+1) = a(n) + 2^k + 2^(m-1) - 1 + floor((2^(k+m) - 2^k)/a(n))*(2^(2*m) + 2^(m-1)) where k is the largest integer such that 2^k divides a(n) and m is the largest integer such that 2^m divides a(n)/2^k+1. - Ulrich Schimke (UlrSchimke(AT)aol.com)
A145037(a(n)) = 0. - Reikku Kulon, Oct 02 2008
Comments
Examples
References
Links
Crossrefs
Programs
Haskell
Haskell
MATLAB
Magma
Maple
Mathematica
PARI
PARI
PARI
PARI
Python
Python
Python
Sage
Scheme
Formula
Extensions