A371565 Integers k such that removing the even digits from k! yields a prime number.
6, 7, 8, 9, 10, 13, 18, 20, 21, 23, 25, 82, 119, 137, 2389, 4108, 5875
Offset: 1
Examples
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.
Programs
-
Mathematica
q[n_] := PrimeQ[FromDigits[Select[IntegerDigits[n!], OddQ]]]; Select[Range[200], q] (* Amiram Eldar, Mar 30 2024 *)
-
PARI
isok(k) = my(d=digits(k!)); ispseudoprime(fromdigits(select(x->(x%2), d))); \\ Michel Marcus, Mar 30 2024
-
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
Extensions
a(12)-a(17) from Michael S. Branicky, Mar 27 2024
Comments