Sagot :
Coucou !
Voilà ma solution :
def Eucli(x,y):
if y>x:
r=1
while r!=0:
r=y%x
x,y=y,r
if x==0:
return y
else:
return x
def PGCD(x,y):
ppcm=x*y/Eucli(x,y)
return PGCD
a=int(input("x = "))
b=int(input("y = "))
print("Le PGCD de (",x,",",y,") vaut : ",Eucli(x,y),sep="")
print("Le PPCM de (",x,",",y,") vaut : ",PGCD(x,y),sep="")
Je pense on peut améliorer...
def algoEuclide(a,b):
if b>a:
b,a=a,b
r=1
while r!=0:
r=a%b
a,b=b,r
if a==0:
return b
else:
return a
def PPCM(a,b):
ppcm=a*b/algoEuclide(a,b)
return ppcm
a=int(input("a = "))
b=int(input("b = "))
print("Le PGCD de (",a,",",b,") vaut : ",algoEuclide(a,b),sep="")
print("Le PPCM de (",a,",",b,") vaut : ",PPCM(a,b),sep="")