-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample11.py
More file actions
66 lines (59 loc) · 1.64 KB
/
example11.py
File metadata and controls
66 lines (59 loc) · 1.64 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from time import perf_counter
from math import sqrt, gcd
t1_start = perf_counter()
"""
series = range(2, 50000)
asal_sayilar = []
for num in series:
asal = True
for n in range(2, num):
if num % n == 0:
asal = False
break
if asal == True:
# print(f"{num} bir asal sayidir")
asal_sayilar.append(num)
else:
# print(f"{num} bir asal sayi degildir")
pass
print(asal_sayilar)
"""
a_number = 50000 ** 2 + 1
if a_number > 1:
if gcd(2, a_number) > 1:
print("bu sayi cifttir")
else:
prime_list = [3]
asal = True
for i in prime_list:
if i > sqrt(a_number):
break
if gcd(a_number, i) > 1:
asal = False
break
cift_list = [2]
advoc = i + 2
for c in cift_list:
if c % 2 == 0:
asal_advoc = True
for j in prime_list:
if j > sqrt(advoc):
break
if gcd(j, advoc) > 1:
asal_advoc = False
break
if asal_advoc:
prime_list.append(advoc)
break
else:
advoc = advoc + 2
cift_list.append(c)
if asal:
print("bu sayi asaldir")
else:
print("bu sayi asal degildir")
else:
print("bu sayi asal olamaz")
print(prime_list)
t1_stop = perf_counter()
print("Elapsed time during the whole program in seconds:", t1_stop-t1_start)