OFFSET
1,1
COMMENTS
For k > 4, the number k! is divisible by 10. In fact, for k > 1, the final nonzero digit of k! is even (see A008904). Then, if the even digits of k! are removed, the result is either 0 or an odd number, where the latter are candidates for prime numbers. Thus, with this procedure, it is possible to obtain the following prime numbers, although not in this order of occurrence: 3, 5, 7, 3917, 373757, 5517397, 519917179, 155111333959.
EXAMPLE
13 is a term since 13! = 6227020800 and eliminating the even digits yields the number 7, which is prime.
18 is a term since 18! = 6402373705728000 and eliminating the even digits yields 373757, which is prime.
MATHEMATICA
q[n_] := PrimeQ[FromDigits[Select[IntegerDigits[n!], OddQ]]]; Select[Range[200], q] (* Amiram Eldar, Mar 30 2024 *)
PROG
(Python)
from sympy import isprime
from math import factorial
def ok(n):
r = "".join(d for d in str(factorial(n)) if d in "13579")
return len(r) and isprime(int(r))
print([k for k in range(1000) if ok(k)]) # Michael S. Branicky, Mar 27 2024
(Python) # generator of terms, removing trailing 0's from n!
from sympy import isprime
from itertools import count, islice
def agen():
f = 1
for n in count(1):
f *= n
q, t = divmod(f, 10)
while t == 0:
f = q
q, t = divmod(f, 10)
r = "".join(d for d in str(f) if d in "13579")
if len(r) and isprime(int(r)):
yield n
print(list(islice(agen(), 14))) # Michael S. Branicky, Apr 10 2024
(PARI) isok(k) = my(d=digits(k!)); ispseudoprime(fromdigits(select(x->(x%2), d))); \\ Michel Marcus, Mar 30 2024
CROSSREFS
KEYWORD
nonn,base,more
AUTHOR
Gonzalo Martínez, Mar 27 2024
EXTENSIONS
a(12)-a(17) from Michael S. Branicky, Mar 27 2024
STATUS
approved