Logo

Programming-Idioms

History of Idiom 74 > diff from v13 to v14

Edit summary for version 14 by :

Version 13

2015-09-05, 19:30:19

Version 14

2015-10-29, 14:05: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.

Code
x = gcd a b
Code
x = gcd a b
Imports
import "math/big"
Imports
import "math/big"
Code
x.GCD(nil, nil, a, b)
Code
x.GCD(nil, nil, a, b)
Comments bubble
The first two arguments can be ignored in this use case.

x, a, b have pointer type *big.Int .
Comments bubble
The first two arguments can be ignored in this use case.

x, a, b have pointer type *big.Int .
Demo URL
https://play.golang.org/p/SF-Gj_XnAH
Demo URL
https://play.golang.org/p/SF-Gj_XnAH