Metadata-Version: 2.1
Name: primegenerator
Version: 1.3.1
Summary: Fast primes generator and related functions
Home-page: https://dev.azure.com/MusicalNinjas/MikesMath/_git/primes
Author: Mike Foster
Author-email: i.am.mike.foster@gmail.com
License: EUPL 1.2
Project-URL: Source, https://dev.azure.com/MusicalNinjas/MikesMath/_git/primes
Project-URL: Info & Requests, https://dev.azure.com/MusicalNinjas/MikesMath
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Education
Classifier: Natural Language :: English
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENCE

# Introduction 
Fast `PrimeNumbers` 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 `primesieve` if you wish to pre-calculate a large number of primes.

# Getting Started
Installation: `pip install primegenerator`

## Main usage:
```python
from primegenerator import PrimeNumbers
primes = PrimeNumbers()
for prime in primes:
    ... #do something
    if ... #beware this is an infinite iterator!
        break
```

## Test if number is prime:
```python
from primegenerator import PrimeNumbers
assert 5 in PrimeNumbers()
assert 9 not in PrimeNumbers()
```

## Get a specific prime:
```python
from primegenerator import PrimeNumbers
primes = PrimeNumbers(startat1=True)
assert primes[3] == 5
assert primes[3:5] == [5,7]
```

## Preseed - if you know you need all primes up to n:
```python
from primegenerator import PrimeNumbers
n = 100 #somebignumber
primes = PrimeNumbers.preseed(n)
for prime in primes:
    ... #do something
    if ... #beware this is still an infinite iterator and will keep going past the seed point!
        break
```

## Lowest common multiplier:
```python
from primegenerator import lcm
numbers = [2,3,4]
assert lcm(numbers) == 12
assert lcm(3,4,5) == 60
```

## Sieve:
```python
from primegenerator import primesieve
listofprimes = primesieve(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

# What's New?

### v1.3.1
- Slicing supports negative step

## v1.3.0
- Get a specific prime with `primes[n]` or `primes[n:m]`

### v1.2.1
- `test_wrapper` improvements

## v1.2.0
- `n in PrimeNumbers()` will test if n is prime

## v1.1.0
- `lcm` will take multiple arguments and find lowest common multiplier. (Previously required a single list or tuple)

## v1.0.0
- `PrimeNumbers()` infinite iterator supporting `startat1`, `.preseed()`
- `lcm` to find lowest common multiplier
- `sieve` to return a list of primes


# Coming next...
Able to launch a parallel process to pre-calculate the next prime needed on a separate CPU core
