#QUIZ06

Quiz 6

  1. Write a function to calculate the greatest common denominator of two positive integers using Euclid’s algorithm.

 

print(“Euclid’s algorithm”)

numero1=int(input(“Dame el primer numero: “))
numero2=int(input(“Dame el segundo numero: “))

def gcd (a,b):
if(a==b):
return a
elif (a>b):
return gcd(a-b,b)
else:
return gcd (a,b-a)

resultado=gcd(numero1,numero2)
print(“El maximo comun denominador es:”,resultado)

CC BY-SA 4.0 #QUIZ06 by carlosdanielmartinezblog is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.