Skip to main content

Fastest Prime Number Calculation (checks) logic for python. Also contains other prime number calculation ways

Project description

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`.
    - Deprecating dash (-) separated package names but keeping updated `pip install fast-prime` and `pip install fast-prime-numbers`
    - Access Python code using `from fasterprimes 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fasterprimes-0.0.4.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

fasterprimes-0.0.4-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file fasterprimes-0.0.4.tar.gz.

File metadata

  • Download URL: fasterprimes-0.0.4.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for fasterprimes-0.0.4.tar.gz
Algorithm Hash digest
SHA256 4c32ef8752d410295422c03d054824fd0efb847135e0277451023a726d78d426
MD5 ab8f5462dbbd0a26eaabf6177abd8a55
BLAKE2b-256 9bd34f82246a6d559506c3de6db13697017bf763f3f94d34ae1917fa55bd363d

See more details on using hashes here.

File details

Details for the file fasterprimes-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: fasterprimes-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for fasterprimes-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a559da6ed47a5a95e5f70d69d4e727735673994002783863735218204aae5466
MD5 ca705150af7e45a734d61634c5e73795
BLAKE2b-256 6515ba2c96d5475d10c7a67c176db7e2dae139c0bfed43937e8e53dc8255a46e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page