Tag Archives: gcd

Greatest Common Divisor in Q/KDB+

Euclid’s algorithm : Recursive definition of the gcd function using Euclid’s algorithm is : function gcd(a, b) { if (b = 0) return a else return gcd(b, a mod b) } Solution in Q : g:{$[y=0;:x;:g[y;x mod y]];} Results : … Continue reading

Posted in Q | Tagged , , | Leave a comment