Skip to content

Commit d33999b

Browse files
authored
Add files via upload
Calculates GCD and LCM of input values
1 parent 99b6f56 commit d33999b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

gcd_lcm.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
n1 = int(input())
2+
n2 = int(input())
3+
if n1>n2:
4+
small = n2
5+
else:
6+
small = n1
7+
8+
9+
def gdc():
10+
for i in range(1, small+1):
11+
if n1%i == 0 and n2%i == 0:
12+
gcd1 = i
13+
return gcd1
14+
15+
print(gdc())
16+
17+
18+
def lmc():
19+
lcm1 = int((n1*n2)/gdc())
20+
return lcm1
21+
print(lmc())

0 commit comments

Comments
 (0)