Skip to content

Commit e9b6c0f

Browse files
authored
added program to find HCF or GCD👩‍💻
1 parent 2c6085d commit e9b6c0f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Python program to find H.C.F of two numbers
2+
3+
# define a function
4+
def compute_hcf(x, y):
5+
6+
# choose the smaller number
7+
if x > y:
8+
smaller = y
9+
else:
10+
smaller = x
11+
for i in range(1, smaller+1):
12+
if((x % i == 0) and (y % i == 0)):
13+
hcf = i
14+
return hcf
15+
16+
num1 = 54
17+
num2 = 24
18+
19+
print("The H.C.F. is", compute_hcf(num1, num2))

0 commit comments

Comments
 (0)