A001227 Number of odd divisors of n.
1, 1, 2, 1, 2, 2, 2, 1, 3, 2, 2, 2, 2, 2, 4, 1, 2, 3, 2, 2, 4, 2, 2, 2, 3, 2, 4, 2, 2, 4, 2, 1, 4, 2, 4, 3, 2, 2, 4, 2, 2, 4, 2, 2, 6, 2, 2, 2, 3, 3, 4, 2, 2, 4, 4, 2, 4, 2, 2, 4, 2, 2, 6, 1, 4, 4, 2, 2, 4, 4, 2, 3, 2, 2, 6, 2, 4, 4, 2, 2, 5, 2, 2, 4, 4, 2, 4, 2, 2, 6, 4, 2, 4, 2, 4, 2, 2, 3, 6, 3, 2, 4, 2, 2, 8
Offset: 1
Examples
G.f. = q + q^2 + 2*q^3 + q^4 + 2*q^5 + 2*q^6 + 2*q^7 + q^8 + 3*q^9 + 2*q^10 + ... From _Omar E. Pol_, Nov 30 2020: (Start) For n = 9 there are three odd divisors of 9; they are [1, 3, 9]. On the other hand there are three partitions of 9 into consecutive parts: they are [9], [5, 4] and [4, 3, 2], so a(9) = 3. Illustration of initial terms: Diagram n a(n) _ 1 1 _|1| 2 1 _|1 _| 3 2 _|1 |1| 4 1 _|1 _| | 5 2 _|1 |1 _| 6 2 _|1 _| |1| 7 2 _|1 |1 | | 8 1 _|1 _| _| | 9 3 _|1 |1 |1 _| 10 2 _|1 _| | |1| 11 2 _|1 |1 _| | | 12 2 |1 | |1 | | ... a(n) is the number of horizontal line segments in the n-th level of the diagram. For more information see A286001. (End)
References
- B. C. Berndt, Ramanujan's Notebooks Part V, Springer-Verlag, see p. 487 Entry 47.
- L. E. Dickson, History of the Theory of Numbers. Carnegie Institute Public. 256, Washington, DC, Vol. 1, 1919; Vol. 2, 1920; Vol. 3, 1923, see vol. 1, p. 306.
- J. W. L. Glaisher, On the representations of a number as the sum of two, four, six, eight, ten, and twelve squares, Quart. J. Math. 38 (1907), 1-62 (see p. 4).
- Ronald. L. Graham, Donald E. Knuth, and Oren Patashnik, Concrete Mathematics, 2nd ed. (Addison-Wesley, 1994), see exercise 2.30 on p. 65.
- P. A. MacMahon, Combinatory Analysis, Cambridge Univ. Press, London and New York, Vol. 1, 1915 and Vol. 2, 1916; see vol. 2, p 28.
Links
- N. J. A. Sloane, Table of n, a(n) for n = 1..10000
- K. S. Brown's Mathpages, Partitions into Consecutive Integers.
- Atli Fannar Franklín, Pattern avoidance enumerated by inversions, arXiv:2410.07467 [math.CO], 2024. See pp. 2, 18.
- J. W. L. Glaisher, On the representations of a number as the sum of two, four, six, eight, ten, and twelve squares, Quart. J. Math. 38 (1907), 1-62 (see p. 4 and p. 8).
- A. Heiligenbrunner, Sum of adjacent numbers (in German).
- Christian Kassel and Christophe Reutenauer, Pairs of intertwined integer sequences, arXiv:2507.15780 [math.NT], 2025. See p. 11.
- Gerzson Kéri, The factorization of compressed Chebyshev polynomials and other polynomials related to multiple-angle formulas, Annales Univ. Sci. Budapest (Hungary, 2022) Sect. Comp., Vol. 53, 93-108.
- Mircea Merca, Combinatorial interpretations of a recent convolution for the number of divisors of a positive integer, Journal of Number Theory, Volume 160, March 2016, Pages 60-75, function tau_o(n).
- M. A. Nyblom, On the representation of the integers as a difference of nonconsecutive triangular numbers, Fibonacci Quarterly 39:3 (2001), pp. 256-263.
- R. C. Read, Letter to N. J. A. Sloane, Oct. 29, 1976.
- N. J. A. Sloane, Transforms.
- T. Verhoeff, Rectangular and Trapezoidal Arrangements, J. Integer Sequences, Vol. 2 (1999), Article 99.1.6.
- Eric Weisstein's World of Mathematics, Binomial Number and Odd Divisor Function.
- Eric Weisstein's World of Mathematics, q-Polygamma Function.
- Index entries for "core" sequences.
- Index entries for sequences mentioned by Glaisher.
Crossrefs
Cf. A000005, A000079, A000593, A010054 (char. func.), A038547 (positions of first appearances), A050999, A051000, A051001, A051002, A051731, A054844, A069283, A069288, A109814, A115369, A118235, A118236, A125911, A136655, A183063, A183064, A237593, A247795, A272887, A273401, A279387, A286001.
If this sequence counts gapless sets by sum (by Sylvester's enumeration), these sets are ranked by A073485 and A356956. See also A055932, A066311, A073491, A107428, A137921, A333217, A356224, A356841, A356845.
Dirichlet inverse is A327276.
Programs
-
Haskell
a001227 = sum . a247795_row -- Reinhard Zumkeller, Sep 28 2014, May 01 2012, Jul 25 2011
-
Magma
[NumberOfDivisors(n)/Valuation(2*n, 2): n in [1..100]]; // Vincenzo Librandi, Jun 02 2019
-
Maple
for n from 1 by 1 to 100 do s := 0: for d from 1 by 2 to n do if n mod d = 0 then s := s+1: fi: od: print(s); od: A001227 := proc(n) local a,d; a := 1 ; for d in ifactors(n)[2] do if op(1,d) > 2 then a := a*(op(2,d)+1) ; end if; end do: a ; end proc: # R. J. Mathar, Jun 18 2015
-
Mathematica
f[n_] := Block[{d = Divisors[n]}, Count[ OddQ[d], True]]; Table[ f[n], {n, 105}] (* Robert G. Wilson v, Aug 27 2004 *) Table[Total[Mod[Divisors[n], 2]],{n,105}] (* Zak Seidov, Apr 16 2010 *) f[n_] := Block[{d = DivisorSigma[0, n]}, If[ OddQ@ n, d, d - DivisorSigma[0, n/2]]]; Array[f, 105] (* Robert G. Wilson v *) a[ n_] := Sum[ Mod[ d, 2], { d, Divisors[ n]}]; (* Michael Somos, May 17 2013 *) a[ n_] := DivisorSum[ n, Mod[ #, 2] &]; (* Michael Somos, May 17 2013 *) Count[Divisors[#],?OddQ]&/@Range[110] (* _Harvey P. Dale, Feb 15 2015 *) (* using a262045 from A262045 to compute a(n) = number of subparts in the symmetric representation of sigma(n) *) (* cl = current level, cs = current subparts count *) a001227[n_] := Module[{cs=0, cl=0, i, wL, k}, wL=a262045[n]; k=Length[wL]; For[i=1, i<=k, i++, If[wL[[i]]>cl, cs++; cl++]; If[wL[[i]]
Hartmut F. W. Hoft, Dec 16 2016 *) a[n_] := DivisorSigma[0, n / 2^IntegerExponent[n, 2]]; Array[a, 100] (* Amiram Eldar, Jun 12 2022 *) -
PARI
{a(n) = sumdiv(n, d, d%2)}; /* Michael Somos, Oct 06 2007 */
-
PARI
{a(n) = direuler( p=2, n, 1 / (1 - X) / (1 - kronecker( 4, p) * X))[n]}; /* Michael Somos, Oct 06 2007 */
-
PARI
a(n)=numdiv(n>>valuation(n,2)) \\ Charles R Greathouse IV, Mar 16 2011
-
PARI
a(n)=sum(k=1,round(solve(x=1,n,x*(x+1)/2-n)),(k^2-k+2*n)%(2*k)==0) \\ Charles R Greathouse IV, May 31 2013
-
PARI
a(n)=sumdivmult(n,d,d%2) \\ Charles R Greathouse IV, Aug 29 2013
-
Python
from functools import reduce from operator import mul from sympy import factorint def A001227(n): return reduce(mul,(q+1 for p, q in factorint(n).items() if p > 2),1) # Chai Wah Wu, Mar 08 2021
-
SageMath
def A001227(n): return len([1 for d in divisors(n) if is_odd(d)]) [A001227(n) for n in (1..80)] # Peter Luschny, Feb 01 2012
Formula
Dirichlet g.f.: zeta(s)^2*(1-1/2^s).
Comment from N. J. A. Sloane, Dec 02 2020: (Start)
By counting the odd divisors f n in different ways, we get three different ways of writing the ordinary generating function. It is:
A(x) = x + x^2 + 2*x^3 + x^4 + 2*x^5 + 2*x^6 + 2*x^7 + x^8 + 3*x^9 + 2*x^10 + ...
= Sum_{k >= 1} x^(2*k-1)/(1-x^(2*k-1))
= Sum_{k >= 1} x^k/(1-x^(2*k))
= Sum_{k >= 1} x^(k*(k+1)/2)/(1-x^k) [Ramanujan, 2nd notebook, p. 355.].
(This incorporates comments from Vladeta Jovovic, Oct 16 2002 and Michael Somos, Oct 30 2005.) (End)
G.f.: x/(1-x) + Sum_{n>=1} x^(3*n)/(1-x^(2*n)), also L(x)-L(x^2) where L(x) = Sum_{n>=1} x^n/(1-x^n). - Joerg Arndt, Nov 06 2010
Multiplicative with a(p^e) = 1 if p = 2; e+1 if p > 2. - David W. Wilson, Aug 01 2001
Moebius transform is period 2 sequence [1, 0, ...] = A000035, which means a(n) is the Dirichlet convolution of A000035 and A057427.
a(n) = A113414(2*n). - N. J. A. Sloane, Jan 24 2006 (corrected Nov 10 2007)
Sequence = M*V = A115369 * A000005, where M = an infinite lower triangular matrix and V = A000005, d(n); as a vector: [1, 2, 2, 3, 2, 4, ...]. - Gary W. Adamson, Apr 15 2007
Equals A051731 * [1,0,1,0,1,...]; where A051731 is the inverse Mobius transform. - Gary W. Adamson, Nov 06 2007
a(n) = d(n) if n is odd, or d(n) - d(n/2) if n is even, where d(n) is the number of divisors of n (A000005). (See the Weisstein page.) - Gary W. Adamson, Mar 15 2011
Dirichlet convolution of A000005 and A154955 (interpreted as a flat sequence). - R. J. Mathar, Jun 28 2011
a(A000079(n)) = 1; a(A057716(n)) > 1; a(A093641(n)) <= 2; a(A038550(n)) = 2; a(A105441(n)) > 2; a(A072502(n)) = 3. - Reinhard Zumkeller, May 01 2012
a(n) = 1 + A069283(n). - R. J. Mathar, Jun 18 2015
a(A002110(n)/2) = n, n >= 1. - Altug Alkan, Sep 29 2015
a(n*2^m) = a(n*2^i), a((2*j+1)^n) = n+1 for m >= 0, i >= 0 and j >= 0. a((2*x+1)^n) = a((2*y+1)^n) for positive x and y. - Juri-Stepan Gerasimov, Jul 17 2016
L.g.f.: -log(Product_{k>=1} (1 - x^(2*k-1))^(1/(2*k-1))) = Sum_{n>=1} a(n)*x^n/n. - Ilya Gutkovskiy, Jul 30 2018
G.f.: (psi_{q^2}(1/2) + log(1-q^2))/log(q), where psi_q(z) is the q-digamma function. - Michael Somos, Jun 01 2019
Sum_{k=1..n} a(k) ~ n*log(n)/2 + (gamma + log(2)/2 - 1/2)*n, where gamma is Euler's constant (A001620). - Amiram Eldar, Nov 27 2022
a(n) = Sum_{i=1..n} (-1)^(i+1)*A135539(n,i). - Ridouane Oudra, Apr 13 2023
Comments