We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 1ec7ec3 + ca4b92f commit 1eb70ecCopy full SHA for 1eb70ec
Maths/HCF.py
@@ -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
0 commit comments