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: 22/12/2022
- # Licence : GPL
- # Version : 1.0
- # ---------------------------------------------------------------------------
- """
- Un triplet pythagoricien est un triplet (a, b, c) d'entiers naturels non nuls
- vérifiant la relation de Pythagore : a**2 + b**2 = c**2.
- Exemple : [3,4,5]
- """
- # ---------------------------------------------------------------------------
- import math
- def triangles_pyth(n):
- for a in range(n):
- for b in range(1, a):
- c = math.sqrt( a * a + b * b)
- if c % 1 == 0:
- c=int(c)
- print("["+str(a)+","+str(b)+","+str(c)+"] : "+str(a)+"^2 + " + str(b)+"^2 = "+ str(c)+"^2")
- max = int(input("Soit le coté donné d'un triangle, quelle est sa valeur maximale ? "))
- print("Les triangles pythagoriciens recherchés sont : ")
- triangles_pyth(max)
Advertisement
Add Comment
Please, Sign In to add comment