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

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.2.tar.gz (5.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.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: primegenerators-0.0.2.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.4 Linux/5.19.0-38-generic

File hashes

Hashes for primegenerators-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8bc418c1370bf6c02281def823da3e5612d98b715aeda21eb643ad45c8ae449b
MD5 ad1f278db3947a02b9266f769348ff39
BLAKE2b-256 b581737ddc4a1d74a5f098f35698b21d4a5197c4ab806964db02e2aedcec15c7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: primegenerators-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.4 Linux/5.19.0-38-generic

File hashes

Hashes for primegenerators-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 61dc00b4fffbf952ec07ffaa3c24c949637e280f856fc0e381c7e5ee3410ad7d
MD5 fdf12cc2073ae58e8656492674b8249a
BLAKE2b-256 15c9a6da0889e239a2e263857e354f8e71e6cb84c897822230115d17728f6d5c

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