A090786 Least nonnegative integer k such that n! + n + k + 1 is prime.
0, 0, 0, 1, 0, 1, 0, 3, 14, 7, 0, 5, 16, 53, 4, 27, 6, 13, 18, 69, 8, 9, 8, 73, 106, 15, 32, 19, 38, 193, 76, 95, 46, 3, 62, 25, 94, 273, 4, 57, 12, 19, 54, 27, 2, 193, 54, 185, 4, 33, 10, 219, 0, 17, 168, 15, 92, 49, 224, 233, 210, 707, 68, 207, 2, 127, 216, 5, 14, 61, 68, 785
Offset: 0
Keywords
Examples
a(5)=1 because 5!+5+1+1=127 is prime and 126 is not. a(7)=3 because 7!+7+3+1=5051 is prime and 5048, 5049 and 5050 are not prime.
Links
- Seiichi Manyama, Table of n, a(n) for n = 0..500
Programs
-
Maple
a := proc(n) option remember;local r,m,k: r := n!+n: k := 1: m := r+1: while (not isprime(m)) do k := k+1: while (not igcd(k,n)=1) do k := k+1: od: m := r+k: od: k-1; end; # alternatively: a := proc(n) option remember; nextprime(n!+n)-n!-n-1; end;
-
Mathematica
lnik[n_]:=Module[{c=n!+n+1},If[PrimeQ[c],0,NextPrime[c]-c]]; Array[ lnik, 80,0] (* Harvey P. Dale, Apr 08 2019 *)
-
PARI
a(n) = apply(x->(nextprime(x)-x), n!+n+1); \\ Michel Marcus, Mar 21 2018
Comments