Highest Common Factor In C
int result = 0;
for (int element: input2){
result = gcd(result, element);
if(result == 1)
{
return 1;
}
}
return result;
}
static int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
0 Comments