-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprimetriples.py
49 lines (30 loc) · 1.16 KB
/
primetriples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import primesieve
import numpy as np
#The following code was used to collect data on consecutive primes. Specifically, it iterated through all primes
#under 10000000 and kept count of all instances of a prime ending in x, the next prime ending in y,
#and the next prime ending in z
#e.g. kept count of all instances of a prime ending in 1, the next prime ending in 3, and the next prime ending in 7
# **As well as all other digit triple combinations.
np.set_printoptions(suppress=True)
base = int( input("What base?"))
count = np.zeros( (base,base,base) ) # Create an array of all zeros
prev = 0
mid = 0
curr = 0
it = primesieve.Iterator()
prime = it.next_prime()
# Iterate over the primes below blah
while prime < 1000000:
curr = prime % base
count[prev,mid,curr] += 1
prev = mid
mid = curr
prime = it.next_prime()
print("\nObserving results for base " + str(base))
for x in range(1, base):
print("Primes of form " + str(x) + ":x:y")
for y in range(1, base):
for z in range(1,base):
if (count[x,y,z] > 1):
print("\t"+ str(y) + "." + str(z) + ":::" + str(count[x,y,z]))
##are bases generally preferred to be products of first k primes?