login
Least nonnegative m such that n! - m is prime.
21

%I #64 Jan 15 2022 11:59:41

%S 0,1,1,7,1,1,31,13,11,13,1,23,1,47,53,59,41,101,31,31,73,89,73,149,37,

%T 43,101,31,1,61,1,1,193,113,127,97,1,73,83,131,79,109,109,53,89,79,

%U 103,59,97,179,67,59,127,61,461,277,109,137,139,71,71,101,359,127,317,191,251,103,97,751,163,373,199,167,157,491,317

%N Least nonnegative m such that n! - m is prime.

%C Conjecture: for n >= 3, a(n) is 1 or a prime. - _Amarnath Murthy_, Mar 19 2002

%C a(n) is not divisible by any prime <= n. If a(n) > 1 is composite, then a(n) > n^2. There are no entries up to n = 2000 with a(n) > n^2, and there may be none. - _Robert Israel_, Jul 20 2014

%H Hans Havermann, <a href="/A033933/b033933.txt">Table of n, a(n) for n = 2..2000</a> (terms 2..500 from T. D. Noe)

%H <a href="/index/Fa#factorial">Index entries for sequences related to factorial numbers</a>

%p 0, seq(n! - prevprime(n!), n=3..100); # _Robert Israel_, Jul 15 2014

%t p[n_] := Module[{nf = n!}, nf - NextPrime[nf, -1]]; Join[{0}, Table[p[n], {n, 3, 70}]] (* _Harvey P. Dale_, Jul 07 2012 *)

%o (PARI) for(n=2,70, k=0; while(!isprime(n!-k), k++); print1(k,","))

%o (PARI) vector(66, t, my(n=t+1, f=n!); f-precprime(f)) \\ _Joerg Arndt_, Jul 19 2014

%o (Sage)

%o def A033933(n):

%o if n < 3: return 0

%o f = factorial(n)

%o return f - previous_prime(f)

%o [A033933(n) for n in (2..78)] # _Peter Luschny_, Jul 20 2014

%Y Cf. A002982, A006990, A033932, A056752, A053714.

%K nonn,nice

%O 2,4

%A _Jeff Burch_

%E More terms from _Jud McCranie_

%E a(21) onwards from _Wouter Meeussen_

%E Corrected by _Rick L. Shepherd_, Nov 06 2002