Update: The code is also available in Python in this entry
public long GCD(long numberA, long numberB) {
if (numberB==0)
return numberA;
else
return GCD(numberB, numberA % numberB);
}
Showing posts with label GCD. Show all posts
Showing posts with label GCD. Show all posts
Friday, July 3, 2009
Greatest Common Divisor (Recursion)
Here's a sample solution to solve the GCD recursively.
Email the blog author at: nicholaskeytholeong [at] gmail [dot] com
Subscribe to:
Posts (Atom)