Programming-Idioms

History of Idiom 74 > diff from v40 to v41

Edit summary for version 41 :
[Haskell] Other implementation.

Version 40

2020-11-23, 04:48:31

Version 41

2020-11-23, 04:50:16

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 = gcde(a-b) b
    |   otherwise = gcde a (b-a)
Code
gcd a b
    |   a==b =a
    |   a>b = gcd(a-b) b
    |   otherwise = gcd a (b-a)