Skip to content

Instantly share code, notes, and snippets.

@HotelCalifornia
Created January 14, 2016 16:54
Show Gist options
  • Save HotelCalifornia/5106afd826a1b5358d82 to your computer and use it in GitHub Desktop.
Save HotelCalifornia/5106afd826a1b5358d82 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
primes = []
for i in range(2, 10000):
for j in range(2, i):
if i % j == 0:
break
else:
primes.append(i)
diffs = []
for n in primes:
i = primes.index(n)
if not i + 1 >= len(primes):
diffs.append(primes[i + 1] - n)
summ = 0
for n in diffs:
summ += n
summ /= len(diffs)
print(summ)
diffs.append(0)
plt.plot(primes, diffs)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment