Created
March 11, 2012 05:38
-
-
Save larryv/2015163 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Project Euler, Problem 48 | |
-- | |
-- ========== | |
-- The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317. | |
-- | |
-- Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000. | |
-- ========== | |
-- | |
-- Lawrence Velazquez | |
-- 13 June 2011 | |
-- To keep the sum a little more manageable, we'll filter out any number | |
-- x such that x is divisible by 10. This is because x^x ends in at least | |
-- 10 zeroes and therefore wouldn't effect the last ten digits of the sum. | |
main = print $ reverse . take 10 . reverse . show . sum $ | |
[x ^ x | x <- [1 .. 1000], x `mod` 10 /= 0] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment