CKTIS / Python
math.gcd
Restituisce il massimo comune divisore non negativo di un numero qualsiasi di interi.
Versione: Python 3.14; repository image, production runtime not attested
Sintassi
math.gcd(*integers)Restituisce il massimo comune divisore non negativo di un numero qualsiasi di interi.
Il maggiore intero che divide −12, 18 e 30 è 6. I segni non influiscono.
Tutti zeri o nessun argomento danno 0.
import math
assert math.gcd(-12, 18, 30) == 6 and math.gcd() == 0
assert math.gcd(0, -12) == 12
Esempi
import math
print(math.gcd(-12, 18, 30))
print(math.gcd(0, 0))
Risultato
6 0
Tutti zeri o nessun argomento danno 0.