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-10 of 19 results. Next

A065151 a(n) = prime(1 + A064722(n)).

Original entry on oeis.org

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

Views

Author

Labos Elemer, Oct 19 2001

Keywords

Crossrefs

Programs

  • PARI
    { for (n = 2, 1000, a=prime(n - precprime(n) + 1); write("b065151.txt", n, " ", a) ) } \\ Harry J. Smith, Oct 13 2009

Formula

a(n) = prime(PrimePi(prime(n)) - prime(PrimePi(n)) + 1) = A000040(A000720(A000040(n)) - A000040(A000720(n)) + 1).

A135543 Record number of steps under iterations of "map n to n - (largest prime <= n)" (A064722) until reaching the limiting value 0 or 1. Also, places where A121561 reaches a new record.

Original entry on oeis.org

1, 2, 9, 122, 1357323
Offset: 0

Views

Author

Sergio Pimentel, Feb 22 2008

Keywords

Comments

a(5) must be very large (> 100000000). Can anyone extend the sequence?
Conjecture: there exist positive values of n for which a(n) != A175079(n) - 1. - Jaroslav Krizek, Feb 05 2010
From Thomas R. Nicely's data (see link) it seems that the smallest known prime with following prime gap of length a(4)+1 or more is 90823#/510510 - 1065962 (39279 digits), so a(5) = A104138(a(4)) + a(4) <= 90823#/510510 - 1065962 + 1357323 = A002110(8787)/510510 + 291361. (The bounding primes of this prime gap are only known to be probable primes, but if either of them were not prime, the gap would only be larger and the bound on a(5) would still hold.) - Pontus von Brömssen, Jul 31 2022

Examples

			a(4) = 1357323 because after iterating n - (largest prime <= n) we get:
  1357323 - 1357201 = 122 =>
  122 - 113 = 9 =>
  9 - 7 = 2 =>
  2 - 2 = 0,
which takes 4 steps.
		

Crossrefs

Programs

  • Mathematica
    LrgstPrm[n_] := Block[{k = n}, While[ !PrimeQ@ k, k-- ]; k]; f[n_] := Block[{c = 0, d = n}, While[d > 1, d = d - LrgstPrm@d; c++ ]; c]; lst = {}; record = -1; Do[ a = f@n; If[a > record, record = a; AppendTo[lst, a]; Print@ n], {n, 100}] (* Robert G. Wilson v *)
  • Python
    from sympy import prevprime
    from functools import lru_cache
    from itertools import count, islice
    @lru_cache(maxsize=None)
    def f(n): return 0 if n == 0 or n == 1 else 1 + f(n - prevprime(n+1))
    def agen(record=-1):
        for k in count(1):
            if f(k) > record: record = f(k); yield k
    print(list(islice(agen(), 4))) # Michael S. Branicky, Jul 26 2022

Formula

Iterate n - (largest prime <= n) until reaching 0 or 1. Count the iterations required to reach 0 or 1 and determine if it is a new record.
From Pontus von Brömssen, Jul 31 2022: (Start)
a(n) = A104138(a(n-1)) + a(n-1) for n >= 2.
A121561(a(n)) = n.
a(n) = A175079(n) - 1 for n >= 1, i.e., the conjecture in the Comments is false. This follows from the result that A175078(n) = A121561(n-1) for n >= 2.
(End)

A049711 a(n) = n - prevprime(n).

Original entry on oeis.org

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

Views

Author

Keywords

Comments

All runs end in even numbers at a(p), new highs are found at A000101 and the increasing gap size is A005250. - Robert G. Wilson v, Dec 07 2001
All terms are positive since here the variant 2 (A151799(n) < n) of the prevprime function is used, rather than the variant 1 (A007917(n) <= n). - M. F. Hasler, Sep 09 2015

Crossrefs

Programs

  • Maple
    A049711 := n-> n-prevprime(n);
  • Mathematica
    PrevPrim[n_] := Block[ {k = n - 1}, While[ !PrimeQ[k], k-- ]; Return[k]]; Table[ n - PrevPrim[n], {n, 3, 100} ]
    Array[#-NextPrime[#,-1]&,100,3] (* Harvey P. Dale, Dec 07 2011 *)
  • PARI
    A049711(n)=n-precprime(n-1) \\ M. F. Hasler, Sep 09 2015

Formula

a(n) = A064722(n-1) + 1. - Pontus von Brömssen, Jul 31 2022

A007920 Smallest number k such that n + k is prime.

Original entry on oeis.org

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

Views

Author

R. Muller

Keywords

Comments

a(n) = A007918(n) - n.

Examples

			a(22) = 1 because 22 + 1 = 23, the next higher prime.
a(23) = 0 because 23 is prime.
a(24) = 5 because 24 + 5 = 29, the next higher prime.
a(25) = 4 because 25 + 4 = 29, the next higher prime.
		

Crossrefs

Cf. A064722, A013632 (a slightly different version).

Programs

  • Mathematica
    distToPrime[n_] := If[PrimeQ[n], 0, NextPrime[n] - n]; Array[distToPrime, 110, 0] (* Harvey P. Dale, Sep 19 2011 *)
  • PARI
    a(n)=nextprime(n)-n

Extensions

More terms from Joanna S. Bartlett (s1117611(AT)cedarville.edu)

A121559 Final result (0 or 1) under iterations of {r mod (max prime p <= r)} starting at r = n.

Original entry on oeis.org

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

Views

Author

Kerry Mitchell, Aug 07 2006

Keywords

Comments

Previous name: Find r1 = n modulo p1, where p1 is the largest prime not greater than n. Then find r2 = r1 modulo p2, where p2 is the largest prime not greater than r1. Repeat until the last r is either 1 or 0; a(n) is the last r value.
The sequence has the form of blocks of 0's between 1's. See sequence A121560 for the lengths of the blocks of zeros.
The function r mod (max prime p <= r), which appears in the definition, equals r - (max prime p <= r) = A064722(r), because p <= r < 2*p by Bertrand's postulate, where p is the largest prime less than or equal to r. - Pontus von Brömssen, Jul 31 2022

Examples

			a(9) = 0 because 7 is the largest prime not larger than 9, 9 mod 7 = 2, 2 is the largest prime not greater than 2 and 2 mod 2 = 0.
		

Crossrefs

Cf. A007917 and A064722 (both for the iterations).

Programs

  • Mathematica
    Abs[Table[FixedPoint[Mod[#,NextPrime[#+1,-1]]&,n],{n,110}]] (* Harvey P. Dale, Mar 17 2023 *)
  • PARI
    a(n) = if (n==1, return (1)); na = n; while((nb = (na % precprime(na))) > 1, na = nb); return(nb); \\ Michel Marcus, Aug 22 2014

Formula

a(p) = 0 when p is prime. - Michel Marcus, Aug 22 2014
a(n) = A175077(n+1) - 1. - Pontus von Brömssen, Jul 31 2022
a(n) = A200947(n) mod 2. - Alois P. Heinz, Jun 12 2023

Extensions

New name from Michel Marcus, Aug 22 2014

A121561 The number of iterations of "subtract the largest prime less than or equal to the current value" to go from n to the limiting value 0 or 1.

Original entry on oeis.org

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

Views

Author

Kerry Mitchell, Aug 07 2006

Keywords

Comments

Number of steps to go from n to A121559(n).
The sequence has the form of blocks of numbers; see A121562 for the lengths of those blocks.

Examples

			a(9) = 2 because there are 2 steps in going from 9 to 0 in A121559: 9 mod 7 = 2 and 2 mod 2 = 0.
		

Crossrefs

Cf. A121559, A064722, a(n)=1: A093515, a(n)=2: A093513, a(n)=3: A138026, a(n)=4: A138027.

Programs

  • Mathematica
    LrgstPrm[n_] := Block[{k = n}, While[ !PrimeQ@ k, k-- ]; k]; f[n_] := Block[{c = 0, d = n}, While[d > 1, d = d - LrgstPrm@d; c++ ]; c]; Array[f, 105] (* Robert G. Wilson v, Feb 29 2008 *)
  • Python
    from sympy import prevprime
    def a(n): return 0 if n == 0 or n == 1 else 1 + a(n - prevprime(n+1))
    print([a(n) for n in range(1, 106)]) # Michael S. Branicky, Jul 26 2022

A378367 Greatest non prime power <= n, allowing 1.

Original entry on oeis.org

1, 1, 1, 1, 1, 6, 6, 6, 6, 10, 10, 12, 12, 14, 15, 15, 15, 18, 18, 20, 21, 22, 22, 24, 24, 26, 26, 28, 28, 30, 30, 30, 33, 34, 35, 36, 36, 38, 39, 40, 40, 42, 42, 44, 45, 46, 46, 48, 48, 50, 51, 52, 52, 54, 55, 56, 57, 58, 58, 60, 60, 62, 63, 63, 65, 66, 66
Offset: 1

Views

Author

Gus Wiseman, Nov 29 2024

Keywords

Comments

Non prime powers allowing 1 (A361102) are numbers that are not a prime power (A246655), namely 1, 6, 10, 12, 14, 15, 18, 20, 21, 22, 24, ...

Examples

			The greatest non prime power <= 7 is 6, so a(7) = 6.
		

Crossrefs

Sequences obtained by subtracting each term from n are placed in parentheses below.
For prime we have A007917 (A064722).
For nonprime we have A179278 (A010051 almost).
For perfect power we have A081676 (A069584).
For squarefree we have A070321.
For nonsquarefree we have A378033.
For non perfect power we have A378363.
The opposite is A378372, subtracting n A378371.
For prime power we have A031218 (A276781 - 1).
Subtracting from n gives (A378366).
A000015 gives the least prime power >= n (A378370).
A000040 lists the primes, differences A001223.
A000961 and A246655 list the prime powers, differences A057820.
A024619 and A361102 list the non prime powers, differences A375708 and A375735.
A151800 gives the least prime > n (A013632), weak version A007918 (A007920).
Prime powers between primes: A053607, A080101, A304521, A366833, A377057.
Cf. A356068.

Programs

  • Mathematica
    Table[NestWhile[#-1&,n,PrimePowerQ[#]&],{n,100}]

Formula

a(n) = n - A378366(n).
a(n) = A361102(A356068(n)). - Ridouane Oudra, Aug 22 2025

A378457 Difference between n and the greatest prime power <= n, allowing 1.

Original entry on oeis.org

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

Views

Author

Gus Wiseman, Nov 29 2024

Keywords

Comments

Prime powers allowing 1 are listed by A000961.

Examples

			The greatest prime power <= 6 is 5, so a(6) = 1.
		

Crossrefs

Sequences obtained by subtracting each term from n are placed in parentheses below.
For nonprime we have A010051 (almost) (A179278).
Subtracting from n gives (A031218).
For prime we have A064722 (A007917).
For perfect power we have A069584 (A081676).
For squarefree we have (A070321).
Adding one gives A276781.
For nonsquarefree we have (A378033).
For non perfect power we have (A378363).
For non prime power we have A378366 (A378367).
The opposite is A378370 = A377282-1.
A000015 gives the least prime power >= n.
A000040 lists the primes, differences A001223.
A000961 and A246655 list the prime powers, differences A057820.
A024619 and A361102 list the non prime powers, differences A375708 and A375735.
A151800 gives the least prime > n, weak version A007918.
Prime powers between primes: A053607, A080101, A304521, A366833, A377057.

Programs

  • Mathematica
    Table[n-NestWhile[#-1&,n,#>1&&!PrimePowerQ[#]&],{n,100}]

Formula

a(n) = n - A031218(n).
a(n) = A276781(n) - 1.

A064924 If n is prime then a(n) = n; for the subsequent nonprime positions a(n + k) = (k+1)*n; then at the next prime position a new subsequence begins.

Original entry on oeis.org

2, 3, 6, 5, 10, 7, 14, 21, 28, 11, 22, 13, 26, 39, 52, 17, 34, 19, 38, 57, 76, 23, 46, 69, 92, 115, 138, 29, 58, 31, 62, 93, 124, 155, 186, 37, 74, 111, 148, 41, 82, 43, 86, 129, 172, 47, 94, 141, 188, 235, 282, 53, 106, 159, 212, 265, 318, 59, 118, 61, 122, 183, 244
Offset: 2

Views

Author

Reinhard Zumkeller, Oct 14 2001

Keywords

Comments

A064920(a(n)) = n.

Examples

			a(7) = A007917(7) * (A064722(7) + 1) = 7 * (0 + 1) = 7; a(8) = A007917(8) * (A064722(8) + 1) = 7 * (1 + 1) = 14; a(9) = A007917(9) * (A064722(9) + 1) = 7 * (2 + 1) = 21; a(10) = A007917(10) * (A064722(10) + 1) = 7 * (3 + 1) = 28; a(11) = 11.
		

Crossrefs

Programs

  • Haskell
    import Data.List (genericTake)
    a064924 n = a064924_list !! (n-1)
    a064924_list = concat $ zipWith (\p g -> genericTake g [p, 2 * p ..])
       a000040_list $ zipWith (-) (tail a000040_list) a000040_list
    -- Reinhard Zumkeller, Jul 05 2013
  • Mathematica
    a[n_?PrimeQ] := n; a[n_] := NextPrime[n, -1]*(n - NextPrime[n, -1] + 1); Table[a[n], {n, 2, 64}] (* Jean-François Alcover, Sep 19 2011 *)
    Flatten[First[#]Range[Last[#]-First[#]]&/@Partition[Prime[Range[20]],2,1]] (* Harvey P. Dale, May 03 2012 *)
  • PARI
    { for (n=2, 10000, if (isprime(n), a=m=n; k=2, a=k*m; k++); write("b064924.txt", n, " ", a) ) } \\ Harry J. Smith, Sep 29 2009
    

Formula

a(n) = A007917(n) * (A064722(n) + 1)

A072681 a(n) = (n - A007917(n)) * (A007918(n) - n).

Original entry on oeis.org

0, 0, 1, 0, 1, 0, 3, 4, 3, 0, 1, 0, 3, 4, 3, 0, 1, 0, 3, 4, 3, 0, 5, 8, 9, 8, 5, 0, 1, 0, 5, 8, 9, 8, 5, 0, 3, 4, 3, 0, 1, 0, 3, 4, 3, 0, 5, 8, 9, 8, 5, 0, 5, 8, 9, 8, 5, 0, 1, 0, 5, 8, 9, 8, 5, 0, 3, 4, 3, 0, 1, 0, 5, 8, 9, 8, 5, 0, 3, 4, 3, 0, 5, 8, 9, 8, 5, 0, 7, 12, 15, 16, 15, 12, 7, 0, 3, 4, 3, 0, 1, 0
Offset: 2

Views

Author

Reinhard Zumkeller, Jul 01 2002

Keywords

Comments

a(n)=0 iff n is prime.
Local maxima occur at interprimes: a(A024675(n)) = A074927(n+1). - Reinhard Zumkeller, Mar 04 2009
Expanding upon the maxima comment, repetitive subset triplets (like 3,4,3) of form (k,k+1,k) occur when the middle value is a square. - Bill McEachen, Apr 14 2025

Crossrefs

Programs

  • Mathematica
    a[n_] := (n - NextPrime[n+1, -1])*(NextPrime[n] - n); Table[a[n], {n, 2, 103}] (* Jean-François Alcover, Jun 14 2013 *)

Formula

a(n) = A064722(n) * A007920(n).
a(n) = A064722(n) * (A072680(n) - A064722(n)).
Showing 1-10 of 19 results. Next