#!/usr/bin/python import ozLib sum = 0; primes = ozLib.primesTo(2000000) for i in primes: sum += i; print sum """ old version - less efficent way import math def isPrime(num): for i in range(2, int(math.sqrt(num)+1)): if num%i == 0: return 0 return 1 sum = 5 for i in range(5, 2000000, 2): if isPrime(i): sum += i print sum raw_input("press any key to continue...") """
#!/usr/bin/python import ozLib inc = 1 num = 0 found = 0 for prime in ozLib.primesTo(20): inc *= prime while not found: num += inc for divider in range(2, 21): if(num%divider != 0): found = 0 break found = 1 if found: print num else: print "No number like that exists" """ less efficent way i = 0 found = 0 while not found: i += 20 for divider in range(2, 16): if(i % divider != 0): found = 0 break found = 1
#!/usr/bin/python import ozLib import math primes = ozLib.primesTo(int(math.sqrt(600851475143))) maxPrime = 0 product = 1 i = -1 while product < 600851475143: i += 1 if 600851475143 % primes[i] == 0: maxPrime = primes[i] product *= maxPrime print maxPrime raw_input() """ - less efficent import math import ozLib maxPrime = 0 product = 1 i = 1 while product < 600851475143: i += 2 if ozLib.isPrime(i) and 600851475143%i == 0: maxPrime = i product *= maxPrime print i
#!/usr/bin/python import ozLib import math primes = ozLib.primesTo(int(math.sqrt(600851475143))) maxPrime = 0 product = 1 i = -1 while product < 600851475143: i += 1 if 600851475143 % primes[i] == 0: maxPrime = primes[i] product *= maxPrime print maxPrime raw_input() """ - less efficent import math import ozLib maxPrime = 0 product = 1 i = 1 while product < 600851475143: i += 2 if ozLib.isPrime(i) and 600851475143%i == 0: maxPrime = i product *= maxPrime print i print "finished" raw_input() """
#!/usr/bin/python import ozLib list = ozLib.primesTo(1000000) print list[10000] print "finished" raw_input() """ less efficent way import math def isPrime(num): for i in range(2, int(math.sqrt(num)+1)): if num%i == 0: return 0 return 1 found = 0 counter = 6 i = 13 primeMax = 0 while counter < 10000: i += 2 if isPrime(i): counter += 1 while 1: i += 2 if isPrime(i): primeMax=0 counter += 1 break print i, "counter: ", counter
#!/usr/bin/python import ozLib sum = 0 primes = ozLib.primesTo(2000000) for i in primes: sum += i print sum """ old version - less efficent way import math def isPrime(num): for i in range(2, int(math.sqrt(num)+1)): if num%i == 0: return 0 return 1 sum = 5 for i in range(5, 2000000, 2): if isPrime(i): sum += i print sum raw_input("press any key to continue...") """
#!/usr/bin/python import ozLib list = ozLib.primesTo(1000000) print list[10000] print "finished" raw_input() """ less efficent way import math def isPrime(num): for i in range(2, int(math.sqrt(num)+1)): if num%i == 0: return 0 return 1 found = 0 counter = 6 i = 13 primeMax = 0 while counter < 10000: i += 2 if isPrime(i): counter += 1 while 1: i += 2 if isPrime(i): primeMax=0 counter += 1