Pythagorean triples: Difference between revisions

→‎{{header|Haskell}}: (Pruning out some redundant search space in existing contribution)
(→‎{{header|Haskell}}: Reformatting an existing contribution for slightly more legibility)
(→‎{{header|Haskell}}: (Pruning out some redundant search space in existing contribution))
Line 1,683:
(\(_, a, b, c) -> a + b + c <= n)
[ (prim a b c, a, b, c)
| a <- [1 .. n]xs
, b <- [1drop ..a n]xs
, c <- [1drop ..b n]xs
, a < b && b < c
, a ^ 2 + b ^ 2 == c ^ 2 ]
where
xs = [1 .. n]
prim a b _ = gcd a b == 1
 
9,659

edits