python and R code for playing around with prime numbers
Python R
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
30M swiss prime loneliness.png first commit May 3, 2012
README Update README Mar 7, 2013
calclonelyfromprimes2.py first commit May 3, 2012
graphlonely2.r first commit May 3, 2012
ls3000.csv first commit May 3, 2012
ls30000000.csv first commit May 3, 2012
p100.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
p3000.txt first commit May 3, 2012
p30000.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
p3000000.txt first commit May 3, 2012
p30000000.txt first commit May 3, 2012
p510510.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
p9699690.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pr30000.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pr510510.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pr9699690.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
primes1.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
primetriangle510510_1.png adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
prt30000.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
prt510510.png adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
prt510510.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
prt9699690.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pt3000 added trinum.py and example output for 3000 and 30000 Jun 11, 2012
pt3000.txt added trinum.py and example output for 3000 and 30000 Jun 11, 2012
pt30000.txt added trinum.py and example output for 3000 and 30000 Jun 11, 2012
pt510510.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pt9699690.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pt_510510_1.png adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pt_510510_p.jpg adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pt_510510_p2.jpg adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pt_510510_p_150_200.jpg adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pt_510510_r.jpg adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pt_510510_r2.jpg adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pt_510510_r_150_200.jpg adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
pt_510510_t_150_200.jpg adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptc30000.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptc510510.png adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptc510510.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptcb30000.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptcb30000_150.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptcb30000_50.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptcb510510.png adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptcb510510.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptcr30000.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptcr30000_2.txt adding text files with primes or simulated primes. also coordinate fi… Jun 13, 2012
ptcs510510.png added a file and graph ptcs* starting the number of columns shifted b… Jun 13, 2012
ptcs510510.txt added a file and graph ptcs* starting the number of columns shifted b… Jun 13, 2012
rand_pp.py added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
rand_pp.py~ added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
sieve.py first commit May 3, 2012
sieve_newbiecommented.py added over-commented version of sieve.py to help my learn python Jun 11, 2012
trinum.py added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
trinum.py~ added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
trinum1.py added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
trinum_coord.py added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
trinum_coord.py~ added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
trinum_coord_b.py added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
trinum_coord_b.py~ added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
trinum_coord_rand.py added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
trinum_coord_rand.py~ added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
trinum_rp.py added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012
trinum_rp.py~ added more files for plotting primes, randoms, generating randoms wit… Jun 13, 2012

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)