cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A371565 Integers k such that removing the even digits from k! yields a prime number.

Original entry on oeis.org

6, 7, 8, 9, 10, 13, 18, 20, 21, 23, 25, 82, 119, 137, 2389, 4108, 5875
Offset: 1

Views

Author

Gonzalo Martínez, Mar 27 2024

Keywords

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.

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.
		

Crossrefs

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