0
I was doing a basic exercise for the function While
, he asked to create a program that found the MMC between 2 numbers... I managed to do, but the program continues to print the answer non-stop on loop. Where I went wrong?
num1 = int(input("Digite um número inteiro:"))
num2 = int(input("Digite outro número inteiro:"))
if num1 > num2:
maior = num1
else:
maior = num2
while True:
if maior % num1 == 0 and maior % num2 == 0:
print(maior)
else:
maior += 1
Maybe a break when finding the desired number? Right after the print?
– Jefferson Quesado
@Jeffersonquesado Yes, it works, but the book still hasn’t taught this break: so there must be some way to do without it
– Mateus
So boot as stop condition, instead of making endless loop
– Jefferson Quesado