Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
sqrtSums :: Int
sqrtSums = length (takeWhile (<982) (scanl1 (+) (map sqrt [1..]))) + 1
-- scanで途中経過を知ることができる
main = do
print $ scanl (+) 0 [3,5,2,1]
print $ scanr (+) 0 [3,5,2,1]
print $ scanl1 (\acc x -> if x > acc then x else acc) [3,4,5,3,7,9,2,1]
print $ scanl (flip (:)) [] [3,2,1]
print $ sqrt 130
print $ sqrtSums
print $ sum (map sqrt [1..131])
print $ sum (map sqrt [1..130])
print $ sum (map sqrt [1..129])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.