CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 15:01:25 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=332dc5388b7b7777f8a64003164591cdf18d8c31f1ae07fb2ac5822564699b15a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22Wru_b18ANe9QIeztHNuUP5WOkQ2GhSiy%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cf3b8d98967fa8-BLR
Project Euler, Problem #9, Haskell - Pastebin.com
SHARE
TWEET

Project Euler, Problem #9, Haskell
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- A Pythagorean triplet is a set of three natural numbers, a < b < c,
- -- for which, a^2 + b^2 = c^2. For example,
- -- 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean
- -- triplet for which a + b + c = 1000. Find the product abc.
- -- A more efficient solution
- ac :: Integral t => t -> [t]
- ac c =
- [ a * b * c
- | a <- [1 .. div (1000 - c) 2 - 1]
- , let b = (1000 - c) - a
- , a ^ 2 + b ^ 2 == c ^ 2
- ]
- main :: IO ()
- main = print $ head $ concatMap ac [997,996 .. 3]
- -- 31875000
- -- real 0m0,330s
- -- user 0m0,317s
- -- sys 0m0,012s
- -- ################################################################################################
- -- A less efficient solution
- main :: IO ()
- main =
- print $
- head
- [ x * y * z
- | x <- [1 .. 1000]
- , y <- [1 .. 1000]
- , let z = 1000 - (x + y)
- , x + y + z == 1000
- , x ^ 2 + y ^ 2 == z ^ 2
- , x < y && y < z
- ]
- -- 31875000
- -- real 0m0,782s
- -- user 0m0,777s
- -- sys 0m0,004s
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐ ✅ Free Products Method ✅ ✅ NEVER SEEN BEFOR...
JavaScript | 2 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ S
JavaScript | 3 sec ago | 0.24 KB
-
⭐⭐Exchange Exploit⭐⭐ 5
JavaScript | 6 sec ago | 0.24 KB
-
⭐ G2A Bug ⭐ (Get more on BTC swaps) ✅ NEVER S...
JavaScript | 11 sec ago | 0.24 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 11 sec ago | 0.10 KB
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ 6
JavaScript | 14 sec ago | 0.24 KB
-
✅⭐ Make huge profits on trading ⭐⭐ T
JavaScript | 17 sec ago | 0.24 KB
-
⭐✅ Jack's Profit Method ✅ NEVER SEEN BEF...
JavaScript | 21 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand