Library of functions to classify prime numbers
Project description
primeclassify
A library of functions to classify prime numbers
Each classification function takes an argument, p
, which is assumed
to be a prime number. There also are optional arguments tout
and
store
. tout
is the maximum processing time the function may take
and store
is 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
(p
not a member of that classification), orNone
(could not complete test), or- something other than
False
orNone
(p
a member of that classification) — usuallyTrue
, but sometimes additional information (such as, for twin primes, which primes it is a twin of)
A return value of None
may mean it is literally unknown whether p
is 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 the mer
function will return 'None' for any 'p' larger than M127.
There are in addition a few utility functions.
Example usage
from 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 is
137 is a Chen prime
Classification functions
balanced (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 (returnsFalse
or tuple of its cousins)cuban(p, tout=0, stor=0)
Cuban prime (returnsFalse
or (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 prime with exponentexpt
lartrunc(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 (returnsFalse
or tuple of triples of other three members of quadruplets)primetriplet(p, tout=0, stor=0)
Prime triplet prime (returnsFalse
or 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 (returnsFalse
or 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 (returnsFalse
or 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 (returnsFalse
orn
)wilson(p, tout=0, stor=0)
Wilson primewolsten(p, tout=0, stor=0)
Wolstenhome primewoodall(p, tout=0, stor=0)
Woodall prime
Utility functions
class_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
.extras
give limits for additional arguments.test_classify (fn, limit1, limit2=-1, tout=0, stor=0, extra=None)
Calls functionfn
for primesp
in range [2, limit1] or [limit1, limit2], withtout=tout, stor=stor
, and prints results.extra
is extra argument for functions that take one.
Classifications not included
These are not integer primes:
These are just too hard for me to code!
- Full reptend prime
- Genocchi prime
- Highly cototient prime
- Lucky prime
- Ramanujan prime
- Regular (and irregular) prime
- Supersingular prime (of algebraic number theory)
- Wall-Sun-Sun prime
Author: Rich Holmes
Source repository: https://gitlab.com/rsholmes/primeclassify
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for primeclassify-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 625138e39de2312ae06d494e5d9ca12f97eb1bf88cbcd048231bf470d8a7213e |
|
MD5 | 7dd6ddfbdeefcceff5470973dfca2fc5 |
|
BLAKE2b-256 | 6dd0dfa2df05815122a9d2788ff87282139d664afda7b444dee60df11fd40e2c |