0
Are GCD and HCF same or different? Also what is its code?
2 Respostas
0
GCD and HCF are practically the same thing. If you want to find the GCD between two numbers, here is a function i once made for that purpose. It works for two numbers though, but if you get the idea you can extend it for multiple numbers:
def gcd(a, b):
a = float(a); b=float(b)
if a >b:
smallest = b
else:
smallest = a
counter = smallest; i = 0
while i < counter:
i += 1
if (a%smallest==0) and (b%smallest==0)
factor = smallest
break
smallest -= 1
return factor
0
yes they are same
findGcd(int a, int b){
return (a == 0) ? b : findGcd(b%a, a);
}