Skip to content

Commit 700de33

Browse files
Merge pull request #36 from CrypticGuy/master
Create HCF.py
2 parents ea485d1 + ac7b9df commit 700de33

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Code/HCF.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Program to find HCF in python
2+
3+
def hcf(x, y): # x and y are two integers you can input
4+
# smaller will be used to store the variable for running the shorter loop
5+
ans = 1
6+
if (x < y):
7+
smaller = x
8+
else:
9+
smaller = y
10+
for i in range(2, smaller+1):
11+
if ((x%i == 0) and (y%i == 0)):
12+
ans = i
13+
return ans
14+
15+
print(hcf(27, 6))
16+

0 commit comments

Comments
 (0)