arithmetique.py

Created by remi-aerts04

Created on March 09, 2022

259 Bytes

renvoie le pgcd entre a et b


def pgcd(a,b):
  a,b = max(a,b), min(a,b)
  while a%b != 0 :
    r = a%b
    a = b
    b = r
  return b
    
def pgcd_2(a,b):
    liste_dc = [0] + [i for i in range(1, min(abs(a),abs(b))+1) if a%i == 0 and b%i == 0]
    return liste_dc[-1]