-
Notifications
You must be signed in to change notification settings - Fork 0
/
EasyProgramsPython
158 lines (111 loc) · 2.38 KB
/
EasyProgramsPython
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
def MinDivisor(n):
nn = n ** .5
i = 1
while i<nn:
i += 1
#print(i,nn)
if n % i == 0 :
break
if i == int(nn):
return i
else:
return n
x = int(input())
print(int(MinDivisor(x)))
_______________________________________
def IsPrime(n):
i = 2
nn = n ** .5
while i<=nn:
i += 1
if n % i == 0 :
break
if i == nn:
return "YES"
else:
return "NO"
x = int(input())
print(IsPrime(x))
def IsPrime(n):
nn = n ** .5
i = 2
while n % i != 0:
i += 1
if i > nn:
break
if i == n:
IsPrime = "YES"
else:
IsPrime = "NO"
return IsPrime
x = int(input())
print(IsPrime(x))
_____________________________________
def power(a, n):
if n == 0:
return 1
return a * power(a, n - 1)
a = float(input())
n = int(input())
print(power(a, n))
__________________________---
a = int(input())
n = int(input())
def power(a, n):
if n == 0:
return 1
return a * power(a, n - 1)
def ologin(a, n):
if n % 2 == 0:
return (a * a) ** (n // 2)
else:
return a * a ** (n - 1)
print(ologin(a, n))
_______________________________________-
n = int(input())
m = int(input())
def rf(a, b):
while a != 0 and b != 0:
if a > b:
a = a % b
else:
b = b % a
return (a + b)
nm = rf(n, m)
print(int(n/nm),int(m/nm))
______________________________________________________
week5
a = int(input())
b = int(input())
for i in range(a, b+1):
print(i, end=' ')
print(tuple(range(a,b+1)))
____________________________________________
a = int(input())
b = int(input())
if a<=b:
for i in range(a, b+1):
print(i, end=' ')
else:
for i in range(b, a+1):
print(i, end=' ')
_____________________________________________
a = int(input())
for i in range(a):
print("+___ ",sep="",end="")
print()
for i in range(a):
print("|",i+1," / ",sep="",end="")
print()
for i in range(a):
print("|__\ ",sep="",end="")
print()
for i in range(a):
print("| ",sep="",end="")
________________________________________
a = int(input())
for i in range(a+1):
for j in range(i):
print(j+1,end=" ")
print()
______________________________________________