login
The OEIS Foundation is supported by donations from users of the OEIS and by a grant from the Simons Foundation.

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A241424 Largest number k > 0 such that n - k! is prime, or 0 if no such k exists. 2
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 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,4

COMMENTS

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

LINKS

Robert Israel, Table of n, a(n) for n = 1..10000

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 *)

PROG

(PARI)

a(n)=forstep(k=n, 1, -1, if(ispseudoprime(n-k!), return(k)))

n=1; while(n<150, print1(a(n), ", "); n++)

CROSSREFS

Cf. A175940, A245715.

Sequence in context: A298857 A070680 A054711 * A334671 A294232 A331254

Adjacent sequences:  A241421 A241422 A241423 * A241425 A241426 A241427

KEYWORD

nonn

AUTHOR

Derek Orr, Aug 08 2014

STATUS

approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recent
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified October 15 16:57 EDT 2021. Contains 348033 sequences. (Running on oeis4.)