Fast primes generator and related functions.
Project description
Introduction
Fast primes
generator which caches previous results across instances.
You usually don't need as many primes as the worst-case - eg for the included lcm
(lowest common multiplier) function.
Also provides a very fast sieve
if you wish to pre-calculate a large number of primes.
Getting Started
Installation: pip install primegenerator
##Main usage: from primegenerator import primes primenums = primes() for prime in primenums: ... #do something if ... #beware this is an infinite generator! break
##Preseed - if you know you need all primes up to n: from primegenerator import primes n = 100 #somebignumber primenums = primes.preseed(n) for prime in primenums: ... #do something if ... #beware this is still an infinite generator and will keep going past the seed point! break
##Lowest common multiplier: from primegenerator import lcm numbers = [2,3,4] assert lcm(numbers) == 12
##Sieve: from primegenerator import primes listofprimes = primes.sieve(maxprime)
Build and Test
Tests are written for pytest in /tests/test_*.py
pip -r tests/requirements.txt
for additional imports required for some tests.
Tests are available on the ADO repository (see link below)
/dev
contains some useful stuff for debugging, profiling and further development and is only available on the ADO repository (see link below)
Contribute
Code repository (ADO): https://dev.azure.com/MusicalNinjas/MikesMath/_git/primes Homepage: https://dev.azure.com/MusicalNinjas/MikesMath
Coming soon...
assert 31 in primenums assert primenums[3] == 5
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
Built Distribution
File details
Details for the file primegenerator-0.9.5.tar.gz
.
File metadata
- Download URL: primegenerator-0.9.5.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f1506ddc6c7838ed96ddd76b3f968374485b37ba4217c9e1155f39c8d6e2e19 |
|
MD5 | 4d5112d40a77bcfc7978904b7286dd5f |
|
BLAKE2b-256 | 2f1ab13a44e3fc1857ae4e0151a8b32a94871048bab774f7f5e6e992034a8ed2 |
File details
Details for the file primegenerator-0.9.5-py3-none-any.whl
.
File metadata
- Download URL: primegenerator-0.9.5-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cda43bed1b2b704398c4ff33a96fe58d005697ba828d7dbac2dd45d1ae0fc23 |
|
MD5 | 4441745aeab43a245d8fea792238fba0 |
|
BLAKE2b-256 | 5d0961be5e07b43b82a487c8dc2cc7e1c67fee6a3aa38d8e86ba769acdbadb88 |