-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path16.py
More file actions
44 lines (40 loc) · 1.58 KB
/
16.py
File metadata and controls
44 lines (40 loc) · 1.58 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
#16
# 1-dən istifadəçinin daxil etdiyi ədədə qədər olan sadə ədədləri bir,mürəkkəb ədədləri bir toplayın və format istifadə edərək print etdirin.
a = int(input("Ədəd daxil edin: "))
simple_number_total=0
simple_number_total_string=""
complex_number_total=0
complex_number_total_string=""
new_range =range(1,a)
complex_number=0
simple_number=0
for i in new_range:
if i==2:
simple_number_total_string=simple_number_total_string+str(2)
simple_number_total=simple_number_total+2
else:
for j in range(2,i):
if i%j==0:
simple_number=0
complex_number=i
break
elif j*j==i:
simple_number=0
complex_number=i
break
else:
simple_number=i
complex_number=0
complex_number_total=complex_number_total+complex_number
simple_number_total=simple_number_total+simple_number
if simple_number!=0:
simple_number_total_string =simple_number_total_string +" "+ str(simple_number)
if complex_number!=0:
complex_number_total_string=complex_number_total_string+" "+str(complex_number)
print("""
Daxil etdiyin rəqəm: {}
Sadə ədədlər: {}
Sadə Ədədlərin cəmi: {}
Mürəkkəb ədədlər: {}
Mürəkkəb ədədlərin cəmi {}
""".format(a,simple_number_total_string,simple_number_total,complex_number_total_string,complex_number_total))