python and R code for playing around with prime numbers
Python R
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
30M swiss prime loneliness.png
README
calclonelyfromprimes2.py
graphlonely2.r
ls3000.csv
ls30000000.csv
p100.txt
p3000.txt
p30000.txt
p3000000.txt
p30000000.txt
p510510.txt
p9699690.txt
pr30000.txt
pr510510.txt
pr9699690.txt
primes1.txt
primetriangle510510_1.png
prt30000.txt
prt510510.png
prt510510.txt
prt9699690.txt
pt3000
pt3000.txt
pt30000.txt
pt510510.txt
pt9699690.txt
pt_510510_1.png
pt_510510_p.jpg
pt_510510_p2.jpg
pt_510510_p_150_200.jpg
pt_510510_r.jpg
pt_510510_r2.jpg
pt_510510_r_150_200.jpg
pt_510510_t_150_200.jpg
ptc30000.txt
ptc510510.png
ptc510510.txt
ptcb30000.txt
ptcb30000_150.txt
ptcb30000_50.txt
ptcb510510.png
ptcb510510.txt
ptcr30000.txt
ptcr30000_2.txt
ptcs510510.png
ptcs510510.txt
rand_pp.py
rand_pp.py~
sieve.py
sieve_newbiecommented.py
trinum.py
trinum.py~
trinum1.py
trinum_coord.py
trinum_coord.py~
trinum_coord_b.py
trinum_coord_b.py~
trinum_coord_rand.py
trinum_coord_rand.py~
trinum_rp.py
trinum_rp.py~

README

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 
http://thedjbway.b0llix.net/scientific/primegen.html

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, stevekochscience@gmail.com.  Except possibly the "sieve.py" 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.

Instructions:

1.  (optional) Edit file "sieve.py" 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 sieve.py

2.  (optional) Run "python sieve.py".  This will create a file of type p###.txt which lists all the prime numbers up to 
    value SIZE
    
3.  Edit file "calclonelyfromprimes2.py" and set the SIZE parameter to correspond to a p###.txt file that you want to process

4.  Run "python calclonelyfromprimes2.py".  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, dev.off().  (I don't really
    understand this, but it works)