Find file
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (20 sloc) 1.77 KB
2013-03-07 Note: I have since learned that the Eratothenes sieve is way slower than the Atkin Sieve which DJ Bernstein
uses with "primegen." "In other words, Eratosthenes is past his prime." quoted from
This repository holds some R and python code as well as some csv and text files with lists of prime numbers
Code is public domain, by Steven J. Koch, Except possibly the "" code, which I adapted
from Phillip Dorrell on github "zero-comments". I didn't see his license information there, and it's a small bit of code,
so I'm assuming it's also public domain.
1. (optional) Edit file "" and set the SIZE parameter to the upper limit of primes that you want to generate.
Some files already exist if you don't want to re-run
2. (optional) Run "python". This will create a file of type p###.txt which lists all the prime numbers up to
value SIZE
3. Edit file "" and set the SIZE parameter to correspond to a p###.txt file that you want to process
4. Run "python". If a correct p###.txt file is loaded, it will calculate the loneliness and set the
primes flag. It will output a csv file with name "ls###.csv" and has three columns: integer prime, float loneliness, integer
Swiss prime flag
5. Edit the R file, graphlonely2.r and change the filename to the corresponding ls###.csv file that you want to display
6. Run the R file to display the graph. Magenta circles are the swiss primes. Black circles are loneliness of all the primes.
If you want to save the graph, un-comment the png("filename.png") line and the last line, (I don't really
understand this, but it works)