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

A052180 Last filtering prime for n-th prime p: find smallest prime factor of each of the composite numbers between p and next prime; take maximal value.

Original entry on oeis.org

2, 2, 3, 2, 3, 2, 3, 5, 2, 5, 3, 2, 3, 7, 5, 2, 5, 3, 2, 7, 3, 5, 7, 3, 2, 3, 2, 3, 11, 3, 7, 2, 11, 2, 5, 7, 3, 13, 5, 2, 11, 2, 3, 2, 11, 13, 3, 2, 3, 5, 2, 13, 11, 7, 5, 2, 5, 3, 2, 17, 13, 3, 2, 3, 17, 5, 11, 2, 3, 5, 19, 7, 13, 3, 5, 17, 3, 13, 7, 2, 7, 2, 19, 3, 5, 11, 3, 2, 3, 11, 13, 3, 17
Offset: 2

Views

Author

Labos Elemer, Feb 05 2000

Keywords

Comments

A000879(n) is the least index i such that a(i) = prime(n). - Labos Elemer, May 14 2003

Examples

			For n=9, n-th prime is 23, composites between 23 and next prime are 24 25 26 27 28, smallest prime divisors are 2 5 2 3 2; maximal value is 5, so a(9)=5.
		

Crossrefs

Programs

  • Haskell
    a052180 n = a052180_list !! (n-2)
    a052180_list = f [4..] where
       f ws = (maximum $ map a020639 us) : f vs where
         (us, _:vs) = span  ((== 0) . a010051) ws
    -- Reinhard Zumkeller, Dec 27 2012
    
  • Mathematica
    ffi[x_] := Flatten[FactorInteger[x]];
    lf[x_] := Length[FactorInteger[x]];
    ba[x_] := Table[Part[ffi[x], 2*w-1], {w, 1, lf[x]}];
    mi[x_] := Min[ba[x]];
    Table[Max[Table[mi[ba[w]], {w, Prime[j]+1, -1+Prime[j+1]}]], {j, 2, 256}]
    (* Second program: *)
    mpf[{a_,b_}] := Max[FactorInteger[#][[1,1]]& /@ Range[a+1,b-1]];
    mpf/@ Partition[ Prime[Range[2,100]],2,1] (* Harvey P. Dale, Apr 30 2013 *)
  • PARI
    a(n) = {my(p = prime(n), amax = 0); forcomposite(c = p, nextprime(p+1), amax = max(factor(c)[1,1], amax);); amax;} \\ Michel Marcus, Apr 21 2018
    
  • Python
    from sympy import prime, nextprime, primefactors
    def a(n):
      p = prime(n); q = nextprime(p)
      return max(min(primefactors(m)) for m in range(p+1, q))
    print([a(n) for n in range(2, 95)]) # Michael S. Branicky, Feb 02 2021

Formula

a(n) = Max_{j=1+prime(n)..prime(n+1)-1} A020639(j) where A020639(j) is the least prime dividing j.

A055399 Number of stages of sieve of Eratosthenes needed to identify n as prime or composite.

Original entry on oeis.org

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

Views

Author

Henry Bottomley, May 15 2000

Keywords

Comments

Primes are known as primes actually one step before a(n): at step k of the sieve, multiples of prime(k) are removed, the smallest integer removed being prime(k)^2; every remaining integer less than prime(k+1)^2 will then never be removed, and it is newly known at step k for those between prime(k)^2 and prime(k+1)^2. For example, at step 3, multiples of prime(3) = 5 are removed and remaining integers after this step are prime up to prime(4)^2 = 49; then, 29, 31, 37, 41, 43, 47 are known as prime at step 3. - Jean-Christophe Hervé, Nov 01 2013

Examples

			a(7)=2 because 7 is not removed by the first two stages of the sieve, but is less than the square of the second prime (though not the square of the first); a(35)=3 because 35 is removed in the third stage as a multiple of 5.
		

Crossrefs

Programs

  • Mathematica
    a[n_ /; !PrimeQ[n]] := PrimePi[ FactorInteger[n][[1, 1]]]; a[n_ /; PrimeQ[n]] := PrimePi[ NextPrime[ Sqrt[n]]]; Table[a[n], {n, 3, 107}](* Jean-François Alcover, Jun 11 2012, after formula *)

Formula

If n is composite, a(n) = A055396(n); if n is prime, a(n) = A056811(n)+1. [Corrected by Charles R Greathouse IV, Sep 03 2013]
a(n) = A010051(n)*(A056811(n)+1)+(1-A010051(n))*A055396(n). - Jean-Christophe Hervé, Nov 01 2013

A230773 Minimum number of steps in an alternate definition of the Sieve of Eratosthenes needed to identify n as prime or composite.

Original entry on oeis.org

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

Views

Author

Jean-Christophe Hervé, Oct 30 2013

Keywords

Comments

This sequence differs from A055399 on prime numbers; as they are never removed during the sieve, it is partly a matter of convention to decide at which step they are classified as prime. Because the smallest integer to be removed at step k is prime(k)^2, integers between prime(k)^2 and prime(k+1)^2 and not removed after step k are known as prime after this step.
This is how this sequence is defined for noncomposite numbers (primes and 1): for any noncomposite number n between prime(k)^2 and prime(k+1)^2, a(n) = k. An exception is made for 3 to fit the usual presentation of the sieve, according to which 3 is classified as prime after the first step, that is, a(3) = 1 (it can be argued, though, that running the first step of the sieve is not actually necessary to identify 3 as prime because 3 < prime(1)^2: see the comment on A000040 by Daniel Forgues, referring to 2 and 3 as "forcibly prime" since there are no integers greater than 1 and less than or equal to their respective square roots).

Examples

			By convention, a(1)=a(2)=0, as 1 is not involved in the sieve, and 2 is known as prime before the first step (first integer > 1).
At step 1, multiples of 2 are removed, beginning with 4 = 2*2; 5 and 7 are not removed and cannot be removed at any further step because they are less than 3*3 = 9; therefore, integers from 4 to 8 are all classified as prime or not prime after the first step: a(4) = a(5) = a(6) = a(7) = a(8) = 1.
At step 2, all integers < 5^2 = 25 will be classified because those >= 9 and not already classified at step one are either multiple of 3 or prime; therefore, for 9 <= n < 25, a(n) = 1 if n is even, a(n) = 2 if n is odd.
		

Crossrefs

Formula

a(n) = A010051(n)*(A056811(n) + mod(n^2,3))+(1-A010051(n))*A055396(n)
(that is, if n is prime > 3, a(n) = primepi(firstprimebelow(sqrt(n)); else if n is composite, a(n) = A055396(n)).
a(n) = A055399(n) - A010051(n)*mod(n^2,3).
Showing 1-3 of 3 results.