Skip to main content

Fast Prime Calculations

Fastest Prime Number Calculation (checks) logic and This probably is the BEST solution in the internet as of today 11th March 2022

This same code can be applied in any languages like Python, Go Lang, Java, PHP, Node.js, Javascript, C, C++, .NET, Rust, etc with the same logic and have performance benefits. It is pretty fast based on the number of iterations needed. Performance time checks were not consistent across languages (in my local system - to be direct about wordings). I have not seen this implemented before and has been indigenously done. Feedback and usage is welcome.

Max iterations 16666 for n == 100000 instead of 100000 of conventional way. The iterations counts for different ways for Prime number check 100007 can be seen as follows:

    count: Prime Conventional way for  83 is  81
    Is Prime 83 isPrimeConventionalWay:  True

    count: Prime Squareroot way  83 is  8
    Is Prime 83 isPrimeSquarerootWay:  True

    count: Prime Unconventional way for  83 is  14
    Is Prime 83 prime (SUGGESTED):  True

    count: Prime AKS - Mersenne primes - Fermat's little theorem or whatever way  83 is  2
    Is Prime 83 isprimeAKSWay:  True

    count: Prime Conventional way for  169 is  12
    Is Prime 169 isPrimeConventionalWay:  False

    count: Prime Squareroot way  169 is  12
    Is Prime 169 isPrimeSquarerootWay:  False

    count: Prime Unconventional way for  169 is  1
    Is Prime 169 prime (SUGGESTED):  False

    count: Prime AKS - Mersenne primes - Fermat's little theorem or whatever way  169 is  4
    Is Prime 169 isprimeAKSWay:  False

    count: Prime Conventional way for  100007 is  96
    Is Prime 100007 isPrimeConventionalWay:  False

    count: Prime Squareroot way  100007 is  96
    Is Prime 100007 isPrimeSquarerootWay:  False

    count: Prime Unconventional way for  100007 is  15
    Is Prime 100007 prime (SUGGESTED):  False

    count: Prime AKS - Mersenne primes - Fermat's little theorem or whatever way  100007 is  32
    Is Prime 100007 isprimeAKSWay:  False

    count: Prime Conventional way for  300530164787 is  1180
    Is Prime 300530164787 isPrimeConventionalWay:  False

    count: Prime Squareroot way  300530164787 is  1180
    Is Prime 300530164787 isPrimeSquarerootWay:  False

    count: Prime Unconventional way for  300530164787 is  196
    Is Prime 300530164787 prime (SUGGESTED):  False

    count: Prime AKS - Mersenne primes - Fermat's little theorem or whatever way  300530164787 is  393
    Is Prime 300530164787 isprimeAKSWay:  False

Code Base

Javascript

Javascript Codebase

Python

Python Codebase

    - Install Python code using `pip install fast-prime` and `pip install fast-prime-numbers`
    - Access Python code using `from fast-prime import *`


# # Usage API for python
# pip install fasterprimes
# pip install fast-prime
# pip install fast-prime-numbers

from fasterprimes import *

fast(13)
conventional(13)
sqroot(13)
aks(13)


Stack overflow Link for Calculations

LICENSE

PROPRIETARY LICENSE AGREEMENT ONLY

Release files for fast-prime-numbers 0.0.3

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

Source distribution (sdist)

Source distribution for fast-prime-numbers 0.0.3
File Size Uploaded
fast-prime-numbers-0.0.3.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fast-prime-numbers 0.0.3
File Interpreter ABI Platform
fast_prime_numbers-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / fast-prime-numbers-0.0.3.tar.gz

Download URL fast-prime-numbers-0.0.3.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d0bd2628145a1d4bb19d8c1c577063fbab6e9616b068984764081311ed1be0c4
BLAKE2b-256 checksum
How to use checksums
bc9fbb7a07a12c268da98265b4f50d168c4ba49a4d9a227433272fa035ae8249
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release files / fast_prime_numbers-0.0.3-py3-none-any.whl

Download URL fast_prime_numbers-0.0.3-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
04702845037d441198c48478b85ec8ebc61a874b56862a8032d0c04aea51fbcb
BLAKE2b-256 checksum
How to use checksums
8e17f278613a74f4121f9b8f8518bb6b82c0bc2adff9fa8e47ff2d06eaca6b4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.7

Release history Release notifications | RSS feed

This release

0.0.3 This release

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