Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

euler 30

  • Loading branch information...
commit d9e0f64a2e80b136ef6abdd226d75889289df7e7 1 parent 4006b9f
@andrusha authored
Showing with 13 additions and 0 deletions.
  1. +13 −0 euler/30.hs
View
13 euler/30.hs
@@ -0,0 +1,13 @@
+-- Find the sum of all the numbers that can be written
+-- as the sum of fifth powers of their digits.
+
+--import Data.Char (digitToInt)
+
+pwrSum :: Int -> Int
+pwrSum 0 = 0
+pwrSum n = (n `mod` 10)^5 + pwrSum (n `div` 10)
+
+answer = sum $ filter good [10..(9^5)*7]
+ where good x = pwrSum x == x
+
+main = print answer
Please sign in to comment.
Something went wrong with that request. Please try again.