Can any help with an algo that is fast enough to calculate the gcd of two positive numbers. I think one good approach will be to use __gcd of C++ but it is inbuilt, i want to create my own function. Please help...
Can any help with an algo that is fast enough to calculate the gcd of two positive numbers. I think one good approach will be to use __gcd of C++ but it is inbuilt, i want to create my own function. Please help...
a recursive method will work perfectly
int gcd(int a, int b) { if (a == 0) return b; else return gcd (b % a, a); }
Link
Euclidean algorithm