-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample09.py
More file actions
47 lines (43 loc) · 1.23 KB
/
example09.py
File metadata and controls
47 lines (43 loc) · 1.23 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
from math import gcd, sqrt
a_number = input("bir sayi giriniz: ")
if a_number.isnumeric():
a_number = int(a_number)
else:
print("hatali giris yaptiniz")
exit()
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)