Skip to content

Commit 1eb70ec

Browse files
Merge pull request #61 from CodesOfAnurag/HCF
HCF of multiple elements
2 parents 1ec7ec3 + ca4b92f commit 1eb70ec

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Maths/HCF.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def calcHCF(a,b):
2+
return b if a%b==0 else calcHCF(b, a%b)
3+
4+
if __name__ == '__main__':
5+
6+
n = int(input())
7+
arr = list(map(int, input().split()))
8+
hcf = calcHCF(arr[0], arr[1])
9+
10+
for i in range(2, len(arr)):
11+
hcf = calcHCF(hcf, arr[i])
12+
13+
print(hcf)

Maths/add

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)