def empirical1(): f = open('data', 'w') datas = [prime_10, prime_20, prime_30, prime_40, prime_50, prime_60, prime_70, prime_80, prime_90, prime_100, prime_110, prime_120, prime_150, prime_200, prime_250] for ns in datas: for n in ns: print n, start = timeit.default_timer() r1 = atkin_morain(n) duration = timeit.default_timer() - start print duration, len(r1), r1 f.write(str(n) + ' ' + str(duration) + ' ' + str(len(r1)) + ' ' + str(r1)) f.close()
def experiment(): for i in range(10): random_test(300) print 'done!' print hilbert(-88) print hilbert(-123) n = 17600773329804421013044164003782933115981289392321878318274335494333497909423750776833564592938824735089487193 for n in prime_200: start = timeit.default_timer() r1 = atkin_morain(n) print timeit.default_timer() - start, '\n', r1
def empirical1(): f = open('data', 'w') datas = [ prime_10, prime_20, prime_30, prime_40, prime_50, prime_60, prime_70, prime_80, prime_90, prime_100, prime_110, prime_120, prime_150, prime_200, prime_250 ] for ns in datas: for n in ns: print n, start = timeit.default_timer() r1 = atkin_morain(n) duration = timeit.default_timer() - start print duration, len(r1), r1 f.write( str(n) + ' ' + str(duration) + ' ' + str(len(r1)) + ' ' + str(r1)) f.close()
def prime(n): """ Final Product: Run Miller-Rabin first, use ECPP only when its probable prime. Args: n: Number to be tested Returns: certificate if the number is prime, False otherwise. """ if not n > 0: raise ValueError("input must be greater than 0") repeat = 50 if miller_rabin(n, repeat): cert = atkin_morain(n) if not cert: raise InconsistencyError("ECPP") else: return cert else: return False
def large(): n = 10**499 + 174295123052 + 1 print atkin_morain(n)