Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating resource.
Please try to avoid dependencies to third-party libraries and frameworks.
Implementation edit is for fixing errors and enhancing with metadata.
Instead of changing the code of the snippet, consider creating another Elixir implementation.
function GCD(a,b:int64):int64; var t:int64; begin while b <> 0 do begin t := b; b := a mod b; a := t; end; result := a; end;
int gcd(int a, int b) { while (b != 0) { var t = b; b = a % t; a = t; } return a; }
x = a.gcd(b)
x = gcd a b
const gcd = (a, b) => b === 0 ? a : gcd (b, a % b)
(defn gcd [a b] (if (zero? b) a (recur b (mod a b))))
unsigned long long int GCD(unsigned long long int a, unsigned long long int b) { unsigned long long int c=a%b; if(c==0) return b; return GCD(b, c); }
int gcd(int a, int b) { while (b != 0) { int t = b; b = a % t; a = t; } return a; }
int gcd(int a, int b) { if (b == 0) return a; else return gcd(b, a % b); }
function gcd(m,n) result(answer) implicit none integer(kind=int64),intent(in) :: m, n integer(kind=int64) :: answer,irest,ifirst ifirst=iabs(m) answer=iabs(n) if(answer.eq.0)then answer=ifirst else do irest = mod(ifirst,answer) if(irest == 0) exit ifirst = answer answer = irest enddo answer= iabs(answer) endif end function gcd
function gcd(a, b) if (b ~= 0) then return a else return gcd(y, x%y) end end
gcd a b | a==b =a | a>b = gcd(a-b) b | otherwise = gcd a (b-a)