Quick actions

cmd+k|ctrl+k

Navigation

Languages

pythagorean triples

Snippet info

Language

Haskell

Visibility

public

Author

danielmg17

Created

2019-06-05T22:49:05Z

Updated

2019-06-06T13:34:04Z

import Control.Monad

triples :: Int -> Int -> [(Int,Int,Int)]
triples i n = do
    x <- [i..n]
    y <- [i..n]
    z <- [i..n]
    guard $ (x^2 + y^2 == z^2)
    pure (x,y,z)
    
main = print $ triples 0 10
INFO