Skip to content

Instantly share code, notes, and snippets.

@tamurashingo
Created February 23, 2013 05:31
Show Gist options
  • Save tamurashingo/5018596 to your computer and use it in GitHub Desktop.
Save tamurashingo/5018596 to your computer and use it in GitHub Desktop.
Project Euler 6
{-
1~100までの二乗の和と、1~100までの和の二乗との差分を求める。
1~100までの二乗の和
foldl (+) 0 $ map (^ 2) [1..100]
1~100までの和の二乗
(^ 2) $ foldl (+) 0 [1..100]
-}
let
a = foldl (+) 0 $ map (^ 2) [1..100]
b = (^ 2) $ foldl (+) 0 [1..100]
in
b - a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment