Skip to content

Commit cc4cfac

Browse files
Create HCF of Multiple Numbers.py
1 parent 50e80cb commit cc4cfac

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

HCF of Multiple Numbers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
n=int(input("Enter the Number of Numbers you want to find the HCF for : "))
2+
def hcf(num1,num2):
3+
if(num1==0):
4+
return num2
5+
else:
6+
return hcf(num2%num1,num1)
7+
if n==2:
8+
num1=int(input("Enter the Number : "))
9+
num=int(input("Enter the Number : "))
10+
hcf_calc=hcf(num,num1)
11+
else:
12+
num1=int(input("Enter the Number : "))
13+
num=int(input("Enter the Number : "))
14+
hcf_calc=hcf(num,num1)
15+
for i in range(n-2) :
16+
num=int(input("Enter the Number : "))
17+
hcf_calc=hcf(num,hcf_calc)
18+
print("HCF of given numbers is:",hcf_calc)

0 commit comments

Comments
 (0)