Hướng dẫn dùng calculate gcd trong PHP

[PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8]

gmp_gcdCalculate GCD

Description

gmp_gcd[GMP|int|string $num1, GMP|int|string $num2]: GMP

Parameters

num1

A GMP object, an int or a numeric string.

num2

A GMP object, an int or a numeric string.

Return Values

A positive GMP number that divides into both num1 and num2.

Examples

Example #1 gmp_gcd[] example

The above example will output:

bigkm1 at gmail dot com

16 years ago

here is an elegant recursive solution

sean__remove__ at eternalrise_r_emove__ dot com

13 years ago

Here's my solution for getting the GCD of several numbers.

delboy1978uk at gmail dot com

4 years ago

I wanted this functionality without having to install the extension.

So here's a script I wrote to find out the greatest common denominator:

Chủ Đề