Programming-Idioms

History of Idiom 74 > diff from v43 to v44

Edit summary for version 44 :
New Haskell implementation by user [programming-idioms.org]

Version 43

2020-11-23, 20:00:11

Version 44

2020-11-23, 20:01:09

Idiom #74 Compute GCD

Compute the greatest common divisor x of big integers a and b. Use an integer type able to handle huge numbers.

Idiom #74 Compute GCD

Compute the greatest common divisor x of big integers a and b. Use an integer type able to handle huge numbers.

Variables
x,a,b
Variables
x,a,b
Code
gcd a b
    |   a==b =a
    |   a>b = gcd(a-b) b
    |   otherwise = gcd a (b-a)