login
Numbers n such that n! - n - 1 is prime.
4

%I #19 Mar 05 2021 01:51:13

%S 3,4,10,12,346

%N Numbers n such that n! - n - 1 is prime.

%C Clearly n <> 2 (mod 3). For n>3, n!-n, n!-n+1, ..., n!-3, n!-2 is a sequence of n-1 consecutive composite numbers. Additional terms are greater than 2000.

%C a(5) > 7500. - _Michael S. Branicky_, Mar 04 2021

%t Select[Range[3, 346], PrimeQ[#! - # - 1] &] (* _Arkadiusz Wesolowski_, Jan 04 2012 *)

%o (PARI) for(n=3,2000,if(isprime(n!-n-1),print1(n,",")))

%o (Python)

%o from math import factorial

%o from sympy import isprime

%o def ok(n): return isprime(factorial(n) - n - 1)

%o print([m for m in range(3, 500) if ok(m)]) # _Michael S. Branicky_, Mar 04 2021

%Y Cf. A073444 (corresponding primes), A002982 (n!-1 is prime), A073308 (n!+n+1 is prime).

%K nonn,hard,more

%O 1,1

%A _Rick L. Shepherd_, Jul 31 2002

%E Offset corrected by _Arkadiusz Wesolowski_, Jan 04 2012