Skip to main content

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), or
  • None (could not complete test), or
  • something other than False or None (p a member of that classification) — usually True, 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

Utility functions

  • class_from_list (p, thelist, complete, limit=None) Used internally
  • describe(p, tout=0, stor=0, extras={higgs: (2,), williams: (3, 10)}) Returns a list of classifications passed by p. Functions are called with tout=tout, stor=stor. extras give limits for additional arguments.
  • test_classify (fn, limit1, limit2=-1, tout=0, stor=0, extra=None) Calls function fn for primes p in range [2, limit1] or [limit1, limit2], with tout=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!


Author: Rich Holmes
Source repository: https://gitlab.com/rsholmes/primeclassify

Release files for primeclassify 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for primeclassify 0.1.4
File Size Uploaded
primeclassify-0.1.4.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for primeclassify 0.1.4
File Interpreter ABI Platform
primeclassify-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / primeclassify-0.1.4.tar.gz

Download URL primeclassify-0.1.4.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
72a528bc5e7d0078a6f6ae62772ccf5235d26dd42420d2853d15ab93b6fd93fb
BLAKE2b-256 checksum
How to use checksums
30c810ca87d198e281cf1d4357ecf3e50d62816a466e83caf07f6d3da11c3bba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / primeclassify-0.1.4-py3-none-any.whl

Download URL primeclassify-0.1.4-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
625138e39de2312ae06d494e5d9ca12f97eb1bf88cbcd048231bf470d8a7213e
BLAKE2b-256 checksum
How to use checksums
6dd0dfa2df05815122a9d2788ff87282139d664afda7b444dee60df11fd40e2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.4 This release

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page