A library of prime number generators and analyzers, that also has a command-line interface
Project description
PrimeGenerators - Prime Number Generation and Utilities
Command Line Interface
The prime generator can be run from the command line. The output can be piped or redirected to a separate file or process.
usage: primegenerators [-h] [-c COUNT] [-f {text,json}]
Random number generator and analyzer.
options:
-h, --help show this help message and exit
-c COUNT, --count COUNT
The number of values to generate
-f {text,json}, --format {text,json}
The format of the output
Python Library
The prime generator should be created using the factory method, e.g.:
from primegenerators import get_generator
# Details elided
generator = get_generator("eratosthenes")
for index, prime in enumerate(generator.primes()):
sys.stdout.write(str(prime))
# Further processing and exit conditions
Member Functions
primes() -> Iterator[int]
Generate an endless series of prime numbers, starting with 2.
Returns an iterator over the series of prime numbers.
primes_range(minimum: int, maximum: int) -> Iterator[int]
Return an iterator over the series of prime numbers between minimum and maximum inclusive.
minimum: The minimum number in the series. If this number is not prime, the first number in the series is the first prime higher than this number.
maximum: The maximum number in the series. If this number is not prime, the last number in the series is the last prime lower than this number.
is_prime(number: int) -> bool
Determine whether a given number is prime or not.
number: The number to be checked for prime-ness
Returns True
if the candidate number is prime, otherwise False
prime_factors(self, number: int) -> Counter
Calculate the prime factors of a number.
number: The number to be factorized
Returns a collections.Counter
object containing the prime factors of number
Download Statistics
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
File details
Details for the file primegenerators-0.0.5.tar.gz
.
File metadata
- Download URL: primegenerators-0.0.5.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.6 Linux/6.5.0-10-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36e708da5258a65df2823e38df223bc135ebeee133bc09e02f41bc31038b816c |
|
MD5 | 33ab554d394f4b61edd06e071d4fbf43 |
|
BLAKE2b-256 | e1022b040bb28ae65b716f107b7c093adfdbf41ec12735b3820e8c0da55cd768 |
File details
Details for the file primegenerators-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: primegenerators-0.0.5-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.11.6 Linux/6.5.0-10-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2d48717ce0227bf00a5fff5b8327bcb0c9af66653c4d1bf3651b1b14b0d7b6b |
|
MD5 | bea76972fdbe47020b5f24d539746be1 |
|
BLAKE2b-256 | 3fea3973b1d7321955ca1e19a2785f389bd61effa296caa37669ef8caa8fa536 |