Logo

Programming-Idioms

History of Idiom 74 > diff from v3 to v4

Edit summary for version 4 by :

Version 3

2015-08-21, 13:14:56

Version 4

2015-08-22, 10:21:46

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.

Imports
from fractions import gcd
Code
x = gcd(a, b)
Doc URL
https://docs.python.org/3/library/fractions.html#fractions.gcd