Пример #1
0
 def __init__(self,nonPrimePeriod):
     while True:
         if MillerRabin.miller_rabin(nonPrimePeriod):
             self.period = nonPrimePeriod
             break
         else:
             nonPrimePeriod = nonPrimePeriod + 1
Пример #2
0
import MillerRabin
import time
import sys

if __name__ == "__main__":
	
	# some primes
	lst = []
	for i in range(2, 30):
		if MillerRabin.miller_rabin(i):
			lst.append(i)
	print("{} are the primes up to 30".format(lst))
	
	# some bigger primes
	count = 0
	for i in range(2, 10000):
		if MillerRabin.miller_rabin(i):
			count += 1
	print("{} primes up to 10000 ({}%)".format(count, count/100))
	
	# some time expensive calculation (takes ~18 secs)
	t1 = time.time() 
	
	i = 2
	count = 0
	while i < 1000000:
		if MillerRabin.miller_rabin(i):
			count += 1
		i += 1
		if (i % 100000 == 0):
			print("{}%".format(i/10000))