-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample10.py
More file actions
69 lines (62 loc) · 1.66 KB
/
example10.py
File metadata and controls
69 lines (62 loc) · 1.66 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
67
68
69
"""
a_list = [1]
for i in a_list:
a_list.append(i + 1)
print(a_list)
"""
from time import perf_counter
from math import sqrt, gcd
t1_start = perf_counter()
a_number = 100010077
if a_number > 1:
asal = True
for n in range(2, int(sqrt(a_number))):
if a_number % n == 0:
asal = False
break
if asal == True:
print("bu bir asal sayidir")
else:
print("bu bir asal sayi degildir")
else:
print("bu bir asal sayi degildir")
"""
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(len(prime_list))
t1_stop = perf_counter()
print("Elapsed time during the whole program in seconds:", t1_stop-t1_start)