-
Notifications
You must be signed in to change notification settings - Fork 0
/
46.py
43 lines (35 loc) · 874 Bytes
/
46.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
import time
import math
import sys
ub = 100000
t1 = time.monotonic()
def sieveOfEratosthenesGenCompositeAndPrime (ub):
num = 2
array = [True]*(ub)
while (num*num < ub):
for x in range (2*num,ub,num):
array[x] = False
num += 1
while (array[num] == False):
num+=1
primes = []
composites = []
for x in range (2, len(array)):
if(array[x] == True):
primes.append(x)
else:
composites.append(x)
return (primes, composites)
def isGoldbachOtherConjectureTrue (num,primes):
i = 0
while(primes[i]<num):
if(math.sqrt((num - primes[i])/2)%1 == 0):
return True
i += 1
return False
primesAndComposites = sieveOfEratosthenesGenCompositeAndPrime(ub)
for x in range (0, len(primesAndComposites[1]) -10):
val = primesAndComposites[1][x]
if(val % 2 == 1):
if(isGoldbachOtherConjectureTrue(val, primesAndComposites[0]) == False):
print(val)