login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = p - n!, where p is the second smallest prime > n!.
5

%I #13 Mar 05 2022 14:17:24

%S 2,3,5,7,11,13,19,31,23,19,17,43,73,41,149,41,53,61,109,37,37,71,109,

%T 193,97,173,47,101,229,163,241,83,139,103,83,577,311,47,269,61,61,107,

%U 97,89,379,149,269,83,137,167,281,89,79,443,229,157,179,563,389

%N a(n) = p - n!, where p is the second smallest prime > n!.

%C p-n! where p = nextprime(nextprime(n!)).

%C Is every term a prime?

%H Clark Kimberling, <a href="/A275272/b275272.txt">Table of n, a(n) for n = 1..300</a>

%F a(n) = A187874(n) - A000142(n). - _Michel Marcus_, Mar 05 2022

%e For n = 4, we have n! = 24, so that p = 31 and a(4) = 7.

%t Table[NextPrime[n!, 2] - n!, {n, 1, 150}]

%o (PARI) a(n) = nextprime(nextprime(n!+1)+1) - n!; \\ _Michel Marcus_, Mar 05 2022

%o (Python)

%o from sympy import factorial, nextprime

%o def a(n): fn = factorial(n); return nextprime(nextprime(fn)) - fn

%o print([a(n) for n in range(1, 60)]) # _Michael S. Branicky_, Mar 05 2022

%Y Cf. A037153, A005235, A275273, A275274, A000040.

%Y Cf. A000142, A187874.

%K nonn,easy

%O 1,1

%A _Clark Kimberling_, Jul 23 2016