Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import math
  3. loop=True
  4. def mcd(a, b):
  5.     resto = 0
  6.     while(b > 0):
  7.         resto = b
  8.         b = a % b
  9.         a = resto
  10.     return a
  11. while loop:
  12.     dentro = True
  13.     while dentro:
  14.         entrega = input("Introduce A y B: ")
  15.         data = entrega.split(" ",2)
  16.         numA = int(data[0])
  17.         numB = int(data[1])
  18.         if numA==numB==0:
  19.             print("Adios!")
  20.             loop = False
  21.             break
  22.         if numA>10000 or numA<0:
  23.             print("numero A fuera del rango")
  24.             dentro = True
  25.             continue
  26.         if numB>10000 or numB<1:
  27.             print("numero B fuera del rango")
  28.             dentro = True
  29.             continue
  30.         else:
  31.             dentro = False
  32.             if numA>=0 and numA<10000 and numB>=1 and numB<10000:
  33.                 num1AFac = math.factorial(numA)
  34.                 print("El máximo común divisor de "+str(numA)+"! y ", numB," es ", mcd(num1AFac, numB))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement