
-----------------------------------
randint
Wed Aug 01, 2012 8:57 pm

Euclidean Algorithm (greatest common divisor)
-----------------------------------
Just some fun stuff......the Euclidean Algorithm for finding the greatest common divisor of 2 natural numbers, a and b

-----------------------------------
Panphobia
Sun Nov 18, 2012 3:07 pm

Re: Euclidean Algorithm (greatest common divisor)
-----------------------------------
cant it be done simpler like this? [code]public static int gcd(int m, int n) {
        if ((m % n) == 0) {
            return n;
        } else {
            return gcd(n, m % n);
        }
    }[/code]

-----------------------------------
Panphobia
Sun Nov 18, 2012 3:08 pm

RE:Euclidean Algorithm (greatest common divisor)
-----------------------------------
Sorry didnt read euclidean algorithm, my bad :D

-----------------------------------
randint
Sun Nov 18, 2012 5:18 pm

RE:Euclidean Algorithm (greatest common divisor)
-----------------------------------
Again, not that it is impossible, but recursion somehow sucks...computational complexity
