#!/usr/bin/env python from math import sqrt def n_triangles(p): res = [] for a in xrange(1, p): for b in xrange(a, p): c = sqrt(a*a + b*b) if a + b + c == p: res += [(a, b, c)] return res for p in xrange(3, 1000): t = n_triangles(p) if len(t) > 0: print p, len(t), t
Aucun commentaire:
Enregistrer un commentaire