diff options
| author | Mistivia <i@mistivia.com> | 2025-04-10 00:25:44 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-04-10 00:25:44 +0800 |
| commit | a35ca0e5acf5ce33ff55d9ab2aab2fe84eca3b85 (patch) | |
| tree | d79b81346cbba6caac32a95bab4d82d2a7be7dc9 /0009 | |
| parent | efcc7ccc3d0c35c9f038a79a63f1592d62ab6652 (diff) | |
Special Pythagorean Triplet
Diffstat (limited to '0009')
| -rw-r--r-- | 0009/main.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/0009/main.hs b/0009/main.hs new file mode 100644 index 0000000..ea16a29 --- /dev/null +++ b/0009/main.hs @@ -0,0 +1,11 @@ +triplets = foldl1 (++) $ map triplets1 [1..499] + where triplets1 x = foldl1 (++) $ map triplets2 [x+1..999-x] + where triplets2 y = [(x,y,1000-x-y)] + +theTripet = filter (\(a,b,c) -> a^2 + b^2 == c^2) triplets + +tripletProduct (a,b,c) = a * b * c + +main = do + putStrLn $ show $ tripletProduct $ head theTripet + |
