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.

A305099 Least prime m such that either prime(n)# - m is prime or prime(n)# + m is prime, where p# denotes the product of all primes <= p.

Original entry on oeis.org

3, 3, 7, 11, 13, 17, 19, 23, 37, 41, 67, 59, 47, 47, 67, 59, 61, 89, 89, 103, 79, 83, 89, 97, 103, 131, 113, 127, 223, 191, 163, 179, 389, 239, 151, 167, 173, 239, 199, 191, 199, 223, 233, 593, 293, 457, 227, 311, 373, 257, 307, 313, 283, 277, 271, 307, 307
Offset: 1

Views

Author

David Nicolas Lopez, May 22 2018

Keywords

Comments

Since it is known that the first 2000 terms of A005235 are primes, and the first 1000 terms of A055211 are primes, then the first 1000 terms of this sequence are also the least m > 1 such that prime(n)# - m is prime or prime(n)# + m is prime. - Amiram Eldar, Nov 02 2018

Examples

			For n = 6, the sixth primorial is 30030. The nearest prime such that p(6)# plus or minus prime equals its 30030's closest prime is equal to 17 because 30030+17=30047 which is prime or 30030 - 17 = 30013 which is also prime. Given that we only care about the smallest prime distance to the closest prime to the primorial, then we return 17.
For n = 7, the seventh primorial is 510510. The closest prime to the primorial is 510529 which is 510510 + 19; therefore 19 is in the sequence.
		

References

  • Martin Gardner, The Last Recreations (1997), pp. 194-195.
  • R. K. Guy, Unsolved Problems in Number Theory, Section A2
  • Stephen P. Richards, A Number For Your Thoughts, 1982, p. 200.

Crossrefs

Programs

  • Mathematica
    primorial[n_] := Product[Prime[i], {i, 1, n}]; a[n_] := Module[{k = 2, pr = primorial[n]}, While[! PrimeQ[pr - k] && ! PrimeQ[pr + k], k = NextPrime[k]]; k]; Array[a, 57] (* Amiram Eldar, Oct 31 2018 *)
  • PARI
    a(n) = { my(pr = prod(k=1, n, prime(k)), m=2); while (!isprime(pr-m) && !isprime(pr+m), m = nextprime(m+1)); m;} \\ Michel Marcus, Nov 02 2018
  • Sage
    # returns quasi-fortunate-numbers up to n
    def generateQFN(n):
        quasi_fortunate_numbers = []
        primorialArray = []
        prime = Primes()
        num_length = n+1
        primorial = 1
        for i in range(num_length):
            primorial *= prime[i]
            primorialArray.append(primorial)
        for primorials in primorialArray:
            num = 0
            while num < num_length:
                if is_prime(primorials+prime[num]):
                    quasi_fortunate_numbers.append(prime[num])
                    break
                elif is_prime(primorials-prime[num]):
                    quasi_fortunate_numbers.append(prime[num])
                    break
                num += 1
        return quasi_fortunate_numbers
    generateQFN(7)
    

Formula

a(n) = min(A005235(n), A055211(n)), for n > 1.

Extensions

More terms from Amiram Eldar, Oct 31 2018