Package: primeclassify
primeclassifyA library of functions to classify prime numbersEach classification function takes an argument,p, whichis assumed
to be a prime number. There also are optional argumentstoutandstore.toutis the maximum processing time the function may take
andstoreis the maximum number of data values it can store. These
are self enforced. Some have additional optional arguments.Generally, classifications that depend on a number base assume base 10.Each returns one of:False(pnot a member of that classification), orNone(could not complete test), orsomething other thanFalseorNone(pa member of that classification) — usuallyTrue, but sometimes additional information (such as, for twin primes,
which primes it is a twin of)A return value ofNonemay mean it is literally unknown whetherpis in that classification, or just that the function doesn't know and doesn't care to find out. For example, the largest known Mersenne prime is M82,589,933= 282,589,933− 1, but themerfunction will return 'None' for any 'p' larger than M127.There are in addition a few utility functions.Example usagefrom primeclassify import pc
import sympy

x = 137
# pc functions do not check for primality, do that first
if not sympy.isprime(x):
    print (f"{x} is not prime")
# Test if x is a Chen prime
# Limit time to 0.01 seconds, storage to 1000 numbers
if pc.chen(x, tout=.01, stor=1000):
    print (f"{x} is a Chen prime")Output is137 is a Chen primeClassification functionsbalanced (p, tout=0, stor=0)Balanced primechen (p, tout=0, stor=0)Chen primecircular (p, tout=0, stor=0)Circular primecluster(p, tout=0, stor=0)Cluster primecousin(p, tout=0, stor=0)Cousin prime(returnsFalseor tuple of its cousins)cuban(p, tout=0, stor=0)Cuban prime(returnsFalseor (1 or 2 indicating which series))cullen(p, tout=0, stor=0)Cullen primedelicate(p, tout=0, stor=0)Delicate primedihedral(p, tout=0, stor=0)Dihedral primedbmer(p, tout=0, stor=0)Double Mersenne primeemirp(p, tout=0, stor=0)Emirpeven(p, tout=0, stor=0)Even primefactorial(p, tout=0, stor=0)Factorial primefermat(p, tout=0, stor=0)Fermat primefibo(p, tout=0, stor=0)Fibonacci primefortunate(p, tout=0, stor=0)Fortunate primegood(p, tout=0, stor=0)Good primehappy(p, tout=0, stor=0)Happy primehiggs(p, expt=2, tout=0, stor=0)Higgs primewith exponentexptlartrunc(p, tout=0, stor=0)Left-and-right-truncatable primeltrunc(p, tout=0, stor=0)Left-truncatable primelucas(p, tout=0, stor=0)Lucas primemer(p, tout=0, stor=0)Mersenne primemills(p, tout=0, stor=0)Mills primeminimal(p, tout=0, stor=0)Minimal primemotzkin(p, tout=0, stor=0)Motzkin primensw(p, tout=0, stor=0)Newman–Shanks–Williams primepal(p, tout=0, stor=0)Palindromic primepell(p, tout=0, stor=0)Pell primepelllucas(p, tout=0, stor=0)Pell-Lucas primepermutable(p, tout=0, stor=0)Permutable primepierpont(p, tout=0, stor=0)Pierpont primepillai(p, tout=0, stor=0)Pillai primeprimequadruplet(p, tout=0, stor=0)Prime quadruplet prime(returnsFalseor tuple of triples of other three members of quadruplets)primetriplet(p, tout=0, stor=0)Prime triplet prime(returnsFalseor tuple of duples of other two members of triplets)primorial(p, tout=0, stor=0)Primorial primeproth(p, tout=0, stor=0)Proth primepyth(p, tout=0, stor=0)Pythagorean primequartan(p, tout=0, stor=0)Quartan primerepu(p, tout=0, stor=0)Repunit primertrunc(p, tout=0, stor=0)Right-truncatable primesafe(p, tout=0, stor=0)Safe primesexy(p, tout=0, stor=0)Sexy prime(returnsFalseor tuple of its sexy partners. Yes, I said that.)sophie(p, tout=0, stor=0)Sophie Germain primestrobe(p, tout=0, stor=0)Strobogrammatic primestrong(p, tout=0, stor=0)Strong primesuperprime(p, tout=0, stor=0)Super-primesupersing(p, tout=0, stor=0)Supersingular prime(of moonshine theory)twin(p, tout=0, stor=0)Twin prime(returnsFalseor tuple of its twins.)wagstaff(p, tout=0, stor=0)Wagstaff primewief(p, tout=0, stor=0)Wieferich primewilliams(p, b=3, tout=0, stor=0)Williams prime(returnsFalseorn)wilson(p, tout=0, stor=0)Wilson primewolsten(p, tout=0, stor=0)Wolstenhome primewoodall(p, tout=0, stor=0)Woodall primeUtility functionsclass_from_list (p, thelist, complete, limit=None)Used internallydescribe(p, tout=0, stor=0, extras={higgs: (2,), williams: (3, 10)})Returns a list of classifications passed byp. Functions are called withtout=tout, stor=stor.extrasgive limits for additional arguments.test_classify (fn, limit1, limit2=-1, tout=0, stor=0, extra=None)Calls functionfnfor primespin range [2, limit1] or [limit1, limit2], withtout=tout, stor=stor, and prints results.extrais extra argument for functions that take one.Classifications not includedThese are not integer primes:Eisenstein primeGaussian primeThese are just too hard for me to code!Full reptend primeGenocchi primeHighly cototient primeLucky primeRamanujan primeRegular (and irregular) primeSupersingular prime(of algebraic number theory)Wall-Sun-Sun primeAuthor: Rich HolmesSource repository:https://gitlab.com/rsholmes/primeclassify