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

A245716 Least number k > 0 such that n + k! and n - k! are both prime, or 0 if no such k exists.

Original entry on oeis.org

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

Views

Author

Derek Orr, Jul 30 2014

Keywords

Comments

For a(n) > 0, a(n)! < n for all n. Thus a(n) = 0 is definite.

Examples

			13 + 1! and 13 - 1! are not both prime.
13 + 2! and 13 - 2! are not both prime.
13 + 3! and 13 - 3! are both prime (19 and 7). Thus a(13) = 3.
		

Crossrefs

Programs

  • PARI
    a(n)=for(k=1,n,if(ispseudoprime(n-k!)&&ispseudoprime(n+k!),return(k)))
    vector(150,n,a(n))

A241424 Largest number k > 0 such that n - k! is prime, or 0 if no such k exists.

Original entry on oeis.org

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

Views

Author

Derek Orr, Aug 08 2014

Keywords

Comments

If k > n, n - k! is negative and therefore, not prime.

Crossrefs

Programs

  • Maple
    a:= proc(n) local k, r;
    r:= 0;
    for k from 1 do
       if k! >= n then return r
       elif isprime(n-k!) then r:= k
       fi
    od
    end proc:
    seq(a(n),n=1..100); # Robert Israel, Aug 10 2014
  • Mathematica
    a[n_] := Module[{k, r = 0}, For[k = 1, True, k++, If[k! >= n, Return[r], If[PrimeQ[n - k!], r = k]]]];
    Array[a, 100] (* Jean-François Alcover, Jul 27 2020, after Maple *)
  • PARI
    a(n)=forstep(k=n,1,-1,if(ispseudoprime(n-k!),return(k)))
    n=1;while(n<150,print1(a(n),", ");n++)
Showing 1-2 of 2 results.