Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/emlyn/optimised-primes
Jupyter notebook exploring simple prime generating algorithms
https://github.com/emlyn/optimised-primes
ipython-notebook mathematics numbers prime-numbers python
Last synced: about 1 month ago
JSON representation
Jupyter notebook exploring simple prime generating algorithms
- Host: GitHub
- URL: https://github.com/emlyn/optimised-primes
- Owner: emlyn
- Created: 2017-05-14T23:27:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-03T22:41:32.000Z (over 2 years ago)
- Last Synced: 2024-12-17T12:53:40.573Z (about 2 months ago)
- Topics: ipython-notebook, mathematics, numbers, prime-numbers, python
- Language: Jupyter Notebook
- Homepage: https://emlyn.github.io/optimised-primes
- Size: 3.23 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Optimised Primes
> There's more to them than meets the eye.\
> — Optimus PrimeA Jupyter (Python) notebook exploring a few simple prime generating algorithms in an interactive slideshow.
## Viewing
The easiest way is to just view a pre-generated version of the slideshow or notebook. However, you won't be able to evaluate any code yourself.
### Slides
A static version of the slides, with pre-generated plots, is viewable [here](https://emlyn.github.io/optimised-primes).
### Notebook
Alternatively, you can view it in the normal notebook format on [nbviewer](https://nbviewer.jupyter.org/github/emlyn/optimised-primes/blob/master/Primes.ipynb).
## Running
### Online
If you would like to run the code yourself (and possibly edit it), you can run the notebook online with [binder](https://mybinder.org/v2/gh/emlyn/optimised-primes/master?filepath=Primes.ipynb). It will take a little while to load the environment, then:
- Evaluate the first cell (by pressing `shift+Enter` or `ctrl+Enter`) to initialise the notebook.
- Press the "Enter/Exit RISE Slideshow" button (or press `alt+r`) to start the slideshow.
- Make sure you evaluate each cell in the slideshow (by clicking inside it and pressing `shift+Enter` or `ctrl+Enter`), as later cells will depend on previous results.### Local
You can also run it locally on your computer:
- Clone this repo so that you have a copy of the code locally.
- Run the `pip install -r requirements.txt` to install dependencies (this only has to be done the first time).
- Run `jupyter notebook` to start the notebook server.
- In the browser window that opens click on `Primes.ipynb` to load the notebook.
- Run the notebook (as decribed above).## Credits
The clever algorithm at the end (based on the Sieve of Eratosthenes) was found on a webpage that now appears to be offline.
An archive of it is still viewable on the wayback machine
[here](https://web.archive.org/web/20150710134640/http://diditwith.net/2009/01/20/YAPESProblemSevenPart2.aspx).Timing plots are graphed with [Bokeh](https://bokeh.pydata.org/en/latest/).
Notebook is displayed as slides using [RISE](https://github.com/damianavila/RISE).