4 ms·
Euclidean algorithm as a one-line function: function gcd(a,b){ return b ? gcd(b, a%b) : a; }
by jansan 4y ago
Euclidean algorithm as a one-line function:
function gcd(a,b){ return b ? gcd(b, a%b) : a; }
- racl101 4y agoAn oldie but a goodie.
- FartyMcFarter 4y agoIt also has the nice property that it's tail-recursive.
- gitonthescene 4y agoSame formula in ngn/k: *(*|:)(|!/)/
- hinkley 4y agoThat's brilliantly obnoxious or obnoxiously brilliant. I can't decide which. If A is less than B it calls itself with the terms reversed.