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.

A005087 Number of distinct odd primes dividing n.

Original entry on oeis.org

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

Views

Author

Keywords

Crossrefs

Positions of zeros: A000079.
Positions of ones: A336101.

Programs

  • Haskell
    a005087 n = a001221 n + n `mod` 2 - 1 -- Reinhard Zumkeller, Feb 28 2014
    
  • Mathematica
    nn=100; a=Sum[x^p/(1-x^p), {p, Table[Prime[n],{n,2,nn}]}]; Drop[CoefficientList[Series[a, {x,0,nn}],x],1] (* Geoffrey Critzer, Nov 06 2012 *)
    Array[PrimeNu[#] - Boole[EvenQ[#]] &, 102] (* Lei Zhou, Dec 03 2012 *)
  • PARI
    a(n) = if (n%2, omega(n), omega(n)-1); \\ Michel Marcus, Sep 18 2023
  • Python
    from sympy import primefactors
    def A005087(n): return len(primefactors(n))+(n&1)-1 # Chai Wah Wu, Jul 07 2022
    
  • Sage
    def A005087(n) : return len(prime_divisors(n)) + n % 2 - 1
    [A005087(n) for n in (1..80)]  # Peter Luschny, Feb 01 2012
    

Formula

Additive with a(p^e) = 0 if p = 2, 1 otherwise.
a(n) = A001221(n) - 1 + n mod 2. - Reinhard Zumkeller, Sep 03 2003
O.g.f.: Sum_{p=odd prime} x^p/(1-x^p). - Geoffrey Critzer, Nov 06 2012
Sum_{k=1..n} a(k) = n * log(log(n)) + c * n + O(n/log(n)), where c = A077761 - 1/2 = -0.238502... . - Amiram Eldar, Sep 28 2023

Extensions

More terms from Reinhard Zumkeller, Sep 03 2003