Esempio n. 1
0
def problem50(n):
    primes = EulerSupport.getPrimes(n)
    # print (primes)
    maxLen = 0
    maxPrime = 0
    firstPrime = 0
    for i in range(0, len(primes)):
        total = 0
        tempTotal = 0
        next = i
        primeLen = 0
        while tempTotal < n and next < len(primes):
            tempTotal = tempTotal + primes[next]
            next = next + 1
            if tempTotal in primes:
                primeLen = next - i
                total = tempTotal
        if primeLen > maxLen:
            maxLen = primeLen
            maxPrime = total
            firstPrime = primes[i]
            print("Len: %d, Start: %d, max: %d" % (maxLen, firstPrime, maxPrime))
    print("Len: %d, Start: %d, max: %d" % (maxLen, firstPrime, maxPrime))
Esempio n. 2
0
def problem50(n):
    primes = EulerSupport.getPrimes(n)
    #print (primes)
    maxLen = 0
    maxPrime = 0
    firstPrime = 0
    for i in range(0, len(primes)):
        total = 0
        tempTotal = 0
        next = i
        primeLen = 0
        while (tempTotal < n and next < len(primes)):
            tempTotal = tempTotal + primes[next]
            next = next + 1
            if tempTotal in primes:
                primeLen = next - i
                total = tempTotal
        if primeLen > maxLen:
            maxLen = primeLen
            maxPrime = total
            firstPrime = primes[i]
            print("Len: %d, Start: %d, max: %d" %
                  (maxLen, firstPrime, maxPrime))
    print("Len: %d, Start: %d, max: %d" % (maxLen, firstPrime, maxPrime))
Esempio n. 3
0
import sys
import time
sys.path.append("../SupportFunctions/")
import EulerSupport
print (time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
result = EulerSupport.getPrimes(103)
print(len(result))
print(result[-3:])
print (time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
result = EulerSupport.getPrimes(1000)
print(len(result))
print(result[-3:])
print (time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
print(EulerSupport.isPrime(17))
print(EulerSupport.miller_rabin(19))
print (time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
print (1066340417491710595814572169)
print(EulerSupport.miller_rabin( 10663404174917))
print (time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
print(EulerSupport.miller_rabin( 1066340417491710595814572171))
print (time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
print(EulerSupport.miller_rabin(  19134702400093278081449423917))
print (time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))

Esempio n. 4
0
import sys
import time
sys.path.append("../SupportFunctions/")
import EulerSupport
print(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
result = EulerSupport.getPrimes(103)
print(len(result))
print(result[-3:])
print(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
result = EulerSupport.getPrimes(1000)
print(len(result))
print(result[-3:])
print(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
print(EulerSupport.isPrime(17))
print(EulerSupport.miller_rabin(19))
print(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
print(1066340417491710595814572169)
print(EulerSupport.miller_rabin(10663404174917))
print(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
print(EulerSupport.miller_rabin(1066340417491710595814572171))
print(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))
print(EulerSupport.miller_rabin(19134702400093278081449423917))
print(time.strftime("%Y/%m/%d %H:%M:%S", time.localtime()))