summaryrefslogtreecommitdiff
path: root/miralib/ex/pyths.m
blob: 8301e47f4ee9cada86b92445e60a734e2ece9099 (plain)
1
2
3
4
5
6
7
8
9
||Finds all pythagorean triangles (right triangles with  integer  sides)
||Note  the use of a diagonalising list comprehension, with `//' instead
||of `|'.  To see the triangles, say
||	output

output = lay (map show pyths)
pyths = [(a, b, intsqrt (a*a+b*b)) // a <- [3..]; b<-[a+1..]; is_sq (a*a+b*b)]
intsqrt x = entier (sqrt x)
is_sq y = (intsqrt y) ^ 2 = y