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-4 of 4 results.

A048272 Number of odd divisors of n minus number of even divisors of n.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

abs(a(n)) = (1/2) * (number of pairs (i,j) satisfying n = i^2 - j^2 and -n <= i,j <= n). - Benoit Cloitre, Jun 14 2003
As A001227(n) is the number of ways to write n as the difference of 3-gonal numbers, a(n) describes the number of ways to write n as the difference of e-gonal numbers for e in {0,1,4,8}. If pe(n):=(1/2)*n*((e-2)*n+(4-e)) is the n-th e-gonal number, then 4*a(n) = |{(m,k) of Z X Z; pe(-1)(m+k)-pe(m-1)=n}| for e=1, 2*a(n) = |{(m,k) of Z X Z; pe(-1)(m+k)-pe(m-1)=n}| for e in {0,4} and for a(n) itself is a(n) = |{(m,k) of Z X Z; pe(-1)(m+k)-pe(m-1)=n}| for e=8. (Same for e=-1 see A035218.) - Volker Schmitt (clamsi(AT)gmx.net), Nov 09 2004
An argument by Gareth McCaughan suggests that the average of this sequence is log(2). - Hans Havermann, Feb 10 2013 [Supported by a graph. - Vaclav Kotesovec, Mar 01 2023]
From Keith F. Lynch, Jan 20 2024: (Start)
a(n) takes every possible integer value, positive, negative, and zero. Proof: For all nonnegative integers k, a(3^k) = 1+k, a(2^k) = 1-k.
a(n) takes every possible integer value except 1 and -1 infinitely many times. Proof: a(o^(k-1)) = k and a(4*o^(k-1)) = -k for all positive integers k and odd primes o, of which there are infinitely many. a(n) = 0 iff n = 2 (mod 4). a(n) = 1 iff n = 1. a(n) = -1 iff n = 4.
a(n) takes prime value p only for n = o^(p-1), where o is any odd prime.
Terms have a simple pattern that repeats with a period of 4: Positive, zero, positive, negative.
(End)
Inverse Möbius transform of (-1)^(n+1). - Wesley Ivan Hurt, Jun 22 2024

Examples

			a(20) = -2 because 20 = 2^2*5^1 and (1-2)*(1+1) = -2.
G.f. = x + 2*x^3 - x^4 + 2*x^5 + 2*x^7 - 2*x^8 + 3*x^9 + 2*x^11 - 2*x^12 + ...
		

References

  • Louis Comtet, Advanced Combinatorics, Reidel, 1974, p. 162, #16, (6), first formula.
  • S. Ramanujan, Notebooks, Tata Institute of Fundamental Research, Bombay 1957 Vol. 1, see page 97, 7(ii).

Crossrefs

Cf. A048298. A diagonal of A060184.
First differences of A059851.
Indices of records: A053624 (highs), A369151 (lows).

Programs

  • Haskell
    a048272 n = a001227 n - a183063 n  -- Reinhard Zumkeller, Jan 21 2012
    
  • Magma
    [&+[(-1)^(d+1):d in Divisors(n)] :n in [1..95] ]; // Marius A. Burtea, Aug 10 2019
  • Maple
    add(x^n/(1+x^n), n=1..60): series(%,x,59);
    A048272 := proc(n)
        local a;
        a := 1 ;
        for pfac in ifactors(n)[2] do
            if pfac[1] = 2 then
                a := a*(1-pfac[2]) ;
            else
                a := a*(pfac[2]+1) ;
            end if;
        end do:
        a ;
    end proc: # Schmitt, sign corrected R. J. Mathar, Jun 18 2016
    # alternative Maple program:
    a:= n-> -add((-1)^d, d=numtheory[divisors](n)):
    seq(a(n), n=1..100);  # Alois P. Heinz, Feb 28 2018
  • Mathematica
    Rest[ CoefficientList[ Series[ Sum[x^k/(1 - (-x)^k), {k, 111}], {x, 0, 110}], x]] (* Robert G. Wilson v, Sep 20 2005 *)
    dif[n_]:=Module[{divs=Divisors[n]},Count[divs,?OddQ]-Count[ divs, ?EvenQ]]; Array[dif,100] (* Harvey P. Dale, Aug 21 2011 *)
    a[n]:=Sum[-(-1)^d,{d,Divisors[n]}] (* Steven Foster Clark, May 04 2018 *)
    f[p_, e_] := If[p == 2, 1 - e, 1 + e]; a[n_] := Times @@ f @@@ FactorInteger[n]; a[1] = 1; Array[a, 100] (* Amiram Eldar, Jun 09 2022 *)
  • PARI
    {a(n) = if( n<1, 0, -sumdiv(n, d, (-1)^d))}; /* Michael Somos, Jul 22 2006 */
    
  • PARI
    N=17; default(seriesprecision,N); x=z+O(z^(N+1))
    c=sum(j=1,N,j*x^j); \\ log case
    s=-log(prod(j=1,N,(1+x^j)^(1/j)));
    s=serconvol(s,c)
    v=Vec(s) \\ Joerg Arndt, May 03 2008
    
  • PARI
    a(n)=my(o=valuation(n,2),f=factor(n>>o)[,2]);(1-o)*prod(i=1,#f,f[i]+1) \\ Charles R Greathouse IV, Feb 10 2013
    
  • PARI
    a(n)=direuler(p=1,n,if(p==2,(1-2*X)/(1-X)^2,1/(1-X)^2))[n] /* Ralf Stephan, Mar 27 2015 */
    
  • PARI
    {a(n) = my(d = n -> if(frac(n), 0, numdiv(n))); if( n<1, 0, if( n%4, 1, -1) * (d(n) - 2*d(n/2) + 2*d(n/4)))}; /* Michael Somos, Aug 11 2017 */
    

Formula

Coefficients in expansion of Sum_{n >= 1} x^n/(1+x^n) = Sum_{n >= 1} (-1)^(n-1)*x^n/(1-x^n). Expand Sum 1/(1+x^n) in powers of 1/x.
If n = 2^p1*3^p2*5^p3*7^p4*11^p5*..., a(n) = (1-p1)*Product_{i>=2} (1+p_i).
Multiplicative with a(2^e) = 1 - e and a(p^e) = 1 + e if p > 2. - Vladeta Jovovic, Jan 27 2002
a(n) = (-1)*Sum_{d|n} (-1)^d. - Benoit Cloitre, May 12 2003
Moebius transform is period 2 sequence [1, -1, ...]. - Michael Somos, Jul 22 2006
G.f.: Sum_{k>0} -(-1)^k * x^(k^2) * (1 + x^(2*k)) / (1 - x^(2*k)) [Ramanujan]. - Michael Somos, Jul 22 2006
Equals A051731 * [1, -1, 1, -1, 1, ...]. - Gary W. Adamson, Nov 07 2007
From Reinhard Zumkeller, Jan 21 2012: (Start)
a(n) = A001227(n) - A183063(n).
a(A008586(n)) < 0; a(A005843(n)) <= 0; a(A016825(n)) = 0; a(A042968(n)) >= 0; a(A005408(n)) > 0. (End)
a(n) = Sum_{k=0..n} A081362(k)*A015723(n-k). - Mircea Merca, Feb 26 2014
abs(a(n)) = A112329(n) = A094572(n) / 2. - Ray Chandler, Aug 23 2014
From Peter Bala, Jan 07 2015: (Start)
Logarithmic g.f.: log( Product_{n >= 1} (1 + x^n)^(1/n) ) = Sum_{n >= 1} a(n)*x^n/n.
a(n) = A001227(n) - A183063(n). By considering the logarithmic generating functions of these three sequences we obtain the identity
( Product_{n >= 0} (1 - x^(2*n+1))^(1/(2*n+1)) )^2 = Product_{n >= 1} ( (1 - x^n)/(1 + x^n) )^(1/n). (End)
Dirichlet g.f.: zeta(s)*eta(s) = zeta(s)^2*(1-2^(-s+1)). - Ralf Stephan, Mar 27 2015
a(2*n - 1) = A099774(n). - Michael Somos, Aug 12 2017
From Paul D. Hanna, Aug 10 2019: (Start)
G.f.: Sum_{n>=0} x^n * Sum_{k=0..n} binomial(n,k) * (x^(n+1) - x^k)^(n-k) = Sum_{n>=0} a(n)*x^(2*n).
G.f.: Sum_{n>=0} x^n * Sum_{k=0..n} binomial(n,k) * (x^(n+1) + x^k)^(n-k) * (-1)^k = Sum_{n>=0} a(n)*x^(2*n). (End)
a(n) = 2*A000005(2n) - 3*A000005(n). - Ridouane Oudra, Oct 15 2019
Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k)/A000005(k) = 2*log(2)-1. - Amiram Eldar, Mar 01 2023

Extensions

New definition from Vladeta Jovovic, Jan 27 2002

A112329 Number of divisors of n if n odd, number of divisors of n/4 if n divisible by 4, otherwise 0.

Original entry on oeis.org

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

Views

Author

Michael Somos, Sep 04 2005

Keywords

Comments

First occurrence of k: 2, 1, 3, 9, 15, 64, 45, 256, 96, 144, 192, 4096, 240, ????, 768, 576, 480, ????, 720, ..., . See A246063. - Robert G. Wilson v, Oct 31 2013
a(n) is the number of pairs (u, v) in NxZ satisfying u^2-v^2=n. See Kühleitner. - Michel Marcus, Jul 30 2017
The g.f. in the form Sum_{k >= 1} x^(k^2) * (1 + x^(2*k))/(1 - x^(2*k)) = Sum_{k >= 1} x^(k^2) * (1 + x^(2*k))/(1 + x^(2*k) - 2*x^(2*k)) == Sum_{k >= 1} x^(k^2) (mod 2). It follows that a(n) is odd iff n = k^2 for some positive integer k. - Peter Bala, Jan 08 2025

Examples

			x + 2*x^3 + x^4 + 2*x^5 + 2*x^7 + 2*x^8 + 3*x^9 + 2*x^11 + 2*x^12 + ...
		

References

  • G. H. Hardy, Ramanujan: twelve lectures on subjects suggested by his life and work, AMS Chelsea Publishing, Providence, Rhode Island, 2002, p. 142.

Crossrefs

Programs

  • Maple
    f:= proc(n) if n::odd then numtheory:-tau(n) elif n mod 4 = 0 then numtheory:-tau(n/4) else 0 fi end proc;
    seq(f(i),i=1..100); # Robert Israel, Aug 24 2014
  • Mathematica
    Rest[ CoefficientList[ Series[ Sum[x^k/(1 - (-x)^k), {k, 111}], {x, 0, 110}], x]] (* Robert G. Wilson v, Sep 20 2005 *)
    Table[If[OddQ[n],DivisorSigma[0,n],If[OddQ[n/2],0,DivisorSigma[0,n/4]]],{n,100} ] (* Ray Chandler, Aug 23 2014 *)
  • PARI
    {a(n) = if( n<1, 0, (-1)^n * sumdiv( n, d, (-1)^d))}
    
  • PARI
    {a(n) = if( n<1, 0, if( n%2, numdiv(n), if( n%4, 0, numdiv(n/4))))} /* Michael Somos, Sep 02 2006 */
    
  • PARI
    d(n) = if (denominator(n)==1, numdiv(n), 0);
    a(n) = numdiv(n) - 2*d(n/2) + 2*d(n/4); \\ Michel Marcus, Jul 30 2017

Formula

Multiplicative with a(2^e) = e-1 if e>0, a(p^e) = 1+e if p>2.
G.f.: Sum_{k>0} x^k / (1 - (-x)^k) = Sum_{k>0} -(-x)^k / (1 + (-x)^k).
Möbius transform is period 4 sequence [ 1, -1, 1, 1, ...].
G.f.: Sum_{k>=1} x^(k^2) * (1+x^(2*k))/(1-x^(2*k)). - Joerg Arndt, Nov 08 2010
a(4*n + 2) = 0. a(n) = -(-1)^n * A048272(n). a(2*n - 1) = A099774(n). a(4*n) = A000005(n). a(4*n + 1) = A000005(4*n + 1). a(4*n - 1) = 2 * A078703(n).
a(n) = A094572(n) / 2. - Ray Chandler, Aug 23 2014
Bisection: a(2*k-1) = A000005(2*k-1), a(2*k) = A183063(2*k) - A001227(2*k), k >= 1. See the Hardy reference, p. 142 where a(n) = sigma^*0(n). - _Wolfdieter Lang, Jan 07 2017
a(n) = d(n) - 2*d(n/2) + 2*d(n/4) where d(n) = 0 if n is not an integer. See Kühleitner.
a(n) = Sum_{d|n} [(d mod 2) = (n/d mod 2)], where [ ] is the Iverson bracket. - Wesley Ivan Hurt, Mar 21 2022
From Amiram Eldar, Nov 29 2022: (Start)
Dirichlet g.f.: zeta(s)^2*(1 + 2^(1-2*s) - 2^(1-s)).
Sum_{k=1..n} a(k) ~ n*log(n)/2 + (2*gamma-1)*n/2, where gamma is Euler's constant (A001620). (End)
a(n) = (-1)^n * Sum_{d|2*n} cos(d*Pi/2). - Ridouane Oudra, Sep 27 2024

A047486 Numbers that are congruent to {0, 1, 3, 5, 7} mod 8.

Original entry on oeis.org

0, 1, 3, 5, 7, 8, 9, 11, 13, 15, 16, 17, 19, 21, 23, 24, 25, 27, 29, 31, 32, 33, 35, 37, 39, 40, 41, 43, 45, 47, 48, 49, 51, 53, 55, 56, 57, 59, 61, 63, 64, 65, 67, 69, 71, 72, 73, 75, 77, 79, 80, 81, 83, 85, 87, 88, 89
Offset: 1

Views

Author

Keywords

Comments

Also nonnegative integers primitively represented by x^2 - y^2. - Ray Chandler, Aug 23 2014

Crossrefs

Formula

G.f.: x^2*(x^2 + 1)*(1 + x)^2/((x^4 + x^3 + x^2 + x + 1)*(x - 1)^2). - R. J. Mathar, Oct 07 2011
From Wesley Ivan Hurt, Dec 28 2016: (Start)
a(n) = a(n-1) + a(n-5) - a(n-6) for n > 6.
a(n) = (40*n - 40 - 2*(n mod 5) - 2*((n+1) mod 5) - 2*((n+2) mod 5) + 3*((n+3) mod 5) + 3*((n+4) mod 5))/25. (End)

A246063 First occurrence of n in sequence A112329.

Original entry on oeis.org

2, 1, 3, 9, 15, 64, 45, 256, 96, 144, 192, 4096, 240, 16384, 768, 576, 480, 262144, 720, 1048576, 960, 2304, 12288, 16777216, 1440, 5184, 49152, 3600, 3840, 1073741824, 2880, 4294967296, 3360, 36864, 786432, 20736, 5040, 274877906944, 3145728, 147456, 6720
Offset: 0

Views

Author

Ray Chandler, Aug 24 2014

Keywords

Comments

Inspired by a comment from Robert G. Wilson v in sequence A112329.

Crossrefs

Programs

  • Mathematica
    g[lst_,p_]:=Module[{t,i,j},Union[Flatten[Table[t=lst[[i]];t[[j]]=p*t[[j]];Sort[t],{i,Length[lst]},{j,Length[lst[[i]]]}],1],Table[Sort[Append[lst[[i]],p]],{i,Length[lst]}]]];f[n_]:=Module[{i,j,p,e,lst={{}}},{p,e}=Transpose[FactorInteger[n]];Do[lst=g[lst,p[[i]]],{i,Length[p]},{j,e[[i]]}];lst];
    (* above factor functions from T. D. Noe in A162247 *)
    nmax=100;
    a1={2,1,3};
    Do[
    least=Infinity;
    fn=f[n];
    Do[
    exps=Reverse[fnitem]-1;
    odd=even=1;
    cnt=0;
    Do[
    cnt++;
    odd*=(Prime[cnt+1]^exp);
    even*=(Prime[cnt]^exp);
    ,{exp,exps}];
    least=Min[least,odd,4even];
    ,{fnitem,fn}];
    AppendTo[a1,least];
    ,{n,3,nmax}];
    a1
  • PARI
    d(n) = if (denominator(n)==1, numdiv(n), 0);
    f(n) = numdiv(n) - 2*d(n/2) + 2*d(n/4);
    a(n) = {my(k = 1); while (f(k) != n, k++); k;} \\ Michel Marcus, Jul 30 2017

Formula

a(p) = 2^(p+1) for prime p >= 5.
Showing 1-4 of 4 results.