That business with the beeping machine pushed me down a rabbit hole over the weekend, and when I came out I was hanging on to a brand new Python library of functions for checking what classes a prime number belongs to.

It’s on PyPi here , and the source code is on GitLab here .

Note it doesn’t find primes in these categories, it checks whether your prime is in them. You can’t use it to find the next, larger-than-the-largest-known Mersenne prime, for instance. You give each function a prime number and it returns False if it’s not in that category or True (or in some cases some other non-False value) if it is — assuming it’s prime, which it doesn’t check. (After all, if you’re checking a number against all the categories, it’d be dumb to have each function check the primality of the same number.) If it doesn’t know whether it belongs in that category or not, it returns None.

In some cases, it checks the number to see if it fits the definition. Like for palidromic primes, is it a palindrome? If so, it returns True. For others, when the number of primes in that category (or the number known to be in that category) is very small, it just checks against the list. Like this one:

def dbmer(p, tout=0, stor=0):
    """
In mathematics, a double Mersenne number is a Mersenne number of the form

{\displaystyle M_{M_{p}}=2^{2^{p}-1}-1}

where p is prime. 
"""
    return class_from_list (p, [7, 127, 2147483647, 170141183460469231731687303715884105727], False, None)

or this one:

def even(p, tout=0, stor=0):
    """
Primes of the form 2n.
"""
    return p == 2

And no, it does not check for Gaussian primes, or Eisenstein primes, or Ramanujan primes, or Wall-Sun-Sun primes. I suppose for the latter I could just return False if $l p<2^{64}$ and None otherwise, but nah.

I’ve got a program that uses the library; it doesn’t beep, but it does print a message every two seconds:

It is not ready for GitLab yet.