Programming-Idioms

History of Idiom 74 > diff from v21 to v22

Edit summary for version 22 :
New PHP implementation by user [ricardo_sdl]

Version 21

2017-02-07, 22:11:30

Version 22

2018-08-22, 20:35: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
extension=gmp
Code
$x = gmp_gcd($a, $b);
Comments bubble
both $a and $b must be instances of the GMP class
Doc URL
https://secure.php.net/manual/en/function.gmp-gcd.php
Demo URL
https://3v4l.org/bHdmR