Skip to main content

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

Downloads Downloads Downloads

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

primegenerators-0.0.3.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

primegenerators-0.0.3-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file primegenerators-0.0.3.tar.gz.

File metadata

  • Download URL: primegenerators-0.0.3.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.2 Linux/6.2.0-34-generic

File hashes

Hashes for primegenerators-0.0.3.tar.gz
Algorithm Hash digest
SHA256 d6eb32c603a015a779a56fb383c0be9009d73bb1d6491432bb47db91d45ab3c9
MD5 56a50263f1c15d1300c4c30f70b0ca3e
BLAKE2b-256 62a66b15199ac484a8aec209cdd190dc83ca07add93e9a1a59ecd92d5ed66ddb

See more details on using hashes here.

File details

Details for the file primegenerators-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: primegenerators-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.2 Linux/6.2.0-34-generic

File hashes

Hashes for primegenerators-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b5f956744926e9b48877ff07970ee8b2b3f8ee90fd2a79ac2a49e8a38e0b024a
MD5 8eb0abb7897c9519fbe122ff8c6f207f
BLAKE2b-256 1b50a150cc5769d4760b84a29297243632d83d5cbad73065f6466a77587815c1

See more details on using hashes here.

Supported by

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