Re:Algorithms.js – Atwood's Law applied to CS101
by feliperibeiro on Friday May 30, 2014 @09:07AM
(#7821511)
Still this is an issue with the algorithm, not the implementation.
Re:Algorithms.js – Atwood's Law applied to CS101
by conistonwater on Friday May 30, 2014 @09:17AM
(#7821555)
I think you misunderstood the Euclidean algorithm. The basic iteration is of the form
gcd(a, b) = gcd(b, a mod b),
and there is no need to compute mod with anything other than %.
Re:Algorithms.js – Atwood's Law applied to CS101
by feliperibeiro on Friday May 30, 2014 @09:29AM
(#7821618)
You're right. This is the subtraction-based implementation, the division-based is the original and better one :)
https://github.com/felipernb/algorithms.js/commit/e5a04f9ad0...
Edit: Also, if you stick to the original subtraction-based version of the algorithm, why adding that other optimization? That wasn't part of the original algorithm, either. This seems to be double standard.