def primer():
p = 3
while True:
is_prime = True
for x in xrange(2, p):
if p % x == 0:
is_prime = False
break
if is_prime:
yield p
p += 2
give_prime = primer()
primes = [1, 2] # had to separate this into 2 lines because Python
primes.extend([give_prime.next() for x in xrange(9998)]) # so we get 10,000 primes
primes_dict = {}
for i in xrange(len(primes) - 1):
p0 = str(primes[i])[-1]
p1 = str(primes[i + 1])[-1]
key = "".join([p0, "-", p1])
try:
primes_dict[key] += 1
except:
primes_dict[key] = 1
# let's delete the 4 outliers from the begining
del(primes_dict["1-2"])
del(primes_dict["2-3"])
del(primes_dict["3-5"])
del(primes_dict["5-7"])
So long story short, my results over 10,000 primes: In [57]: primes_dict
Out[57]:
{'1-1': 365,
'1-3': 833,
'1-7': 889,
'1-9': 397,
'3-1': 529,
'3-3': 324,
'3-7': 754,
'3-9': 906,
'7-1': 655,
'7-3': 722,
'7-7': 323,
'7-9': 808,
'9-1': 935,
'9-3': 635,
'9-7': 541,
'9-9': 379}
And you can clearly see that the tendency to avoid the same last digit is starting to show, thow those that end in 1 are still not showing it completely. Tried with 100,000 primes but the (horrible) algorithm kinda got stuck so I settled with 10,000 to make this a "quick test".Before you go, please believe me I'm sorry for primer() and give_prime. I'll try to never do those kind of things again.
Edit: I've edited this like 5 times already over little typos and bad transcription mistakes I did all over the place. Should work now.