Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- #----------------------------------------------------------------------------
- # Created by : Alain Van Kerckhoven
- # Created Date: 18 juillet 2016
- # Licence : GPL
- # Version : 1.0
- # ---------------------------------------------------------------------------
- """
- Calcule les diviseurs communs de deux nombres, leur PGCD et leur PPCM (avec tuples)
- """
- # ---------------------------------------------------------------------------
- def findDivisors(n1, n2):
- divisors = ()
- for i in range(1, min(n1, n2) + 1):
- if n1%i == 0 and n2%i == 0:
- divisors = divisors + (i,)
- return divisors
- num1 = int(input("Premier nombre : "))
- num2 = int(input("Second nombre : "))
- divisors = findDivisors(num1, num2)
- pgcd = max(divisors)
- ppcm = int(num1*num2/pgcd)
- print("Diviseurs communs :", divisors)
- print("PGCD :", pgcd)
- print("PPCM :", ppcm)
Advertisement
Add Comment
Please, Sign In to add comment