Sunday, August 14, 2011

Problem 30

prob30.hs Problem 30
Filename: prob30.hs
import Char

n = 5

sum_of_powers_matches_x x = x == sum_of_powers x

sum_of_powers x = sum(map (^n) (map (Char.digitToInt) (show(x))))

answer = sum (filter (sum_of_powers_matches_x) [2..1000000])


syntax highlighted by Code2HTML, v. 0.9.1

No comments:

Post a Comment