Skip to main content

A simple collection of prime number related functions.

Project description

PyPrimer

A simple collection of prime number related functions.

Install

$ pip install pyprimer

For bleeding edge

$ pip install git+https://github.com/mentix02/pyprimer

Docs

  • is_prime(int) -> bool
    • Checks if given number n is prime.
>>> from pyprimer import is_prime
>>> is_prime(3)
True
  • primes_till(int) -> List[int]
    • Returns a list of all primes numbers up until n.
>>> from pyprimer import primes_till
>>> primes_till(6)
[2, 3, 5, 7]
  • n_primes(int) -> List[int]
    • Returns a list of first n natural primes numbers.
>>> from pyprimer import n_primes
>>> n_primes(6)
[2, 3, 5, 7, 11, 13]
  • n_prime(int) -> int
    • Returns the nth prime number.
>>> from pyprimer import n_prime
>>> n_prime(13)
41
  • prime_generator() -> Iterator[int]
    • Returns an iterable of ints with each next element being the next prime number.
>>> from pyprimer import prime_generator
>>> total = 0
>>> g = prime_generator()
>>> for n in g:
...   if n == 13:
...     break
...   total += n
>>> print(total)
28

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

pyprimer-0.1.0.tar.gz (2.0 kB view hashes)

Uploaded Source

Built Distribution

pyprimer-0.1.0-py3-none-any.whl (2.5 kB view hashes)

Uploaded Python 3

Supported by

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