LeafPrimes.frink

Download or view LeafPrimes.frink in plain text format


/*
   Program to count frequencies of last digits of prime numbers
   for Jonathan Leaf
    
   This reproduces (and extends) the values found in:
 
   Unexpected biases in the distribution of consecutive primes
   Robert J. Lemke Oliver and Kannan Soundararajan
   https://doi.org/10.1073/pnas.1605366113
   
   https://www.pnas.org/doi/10.1073/pnas.1605366113
*/


num = 100 million

d = new dict

lastPrime = 7
startPrime = nextPrime[lastPrime]

for p = first[primes[startPrime], num]
{
   d.increment[[lastPrime mod 10, p mod 10]]
   lastPrime = p
}

println[formatTable[lexicalSort[d]]]


Download or view LeafPrimes.frink in plain text format


This is a program written in the programming language Frink.
For more information, view the Frink Documentation or see More Sample Frink Programs.

Alan Eliasen, eliasen@mindspring.com