Created
February 11, 2012 16:05
-
-
Save bonipart/1801422 to your computer and use it in GitHub Desktop.
Problem 1 of 3, embed.ly challenge
This file contains 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
import Data.Char | |
--creates list containing each digit from a number | |
intToDigList :: Integral a => a -> [Int] | |
intToDigList = map digitToInt . show; | |
--computes R(n) | |
rN n = sum (intToDigList( (product [1..n]))) | |
--returns the first number,'n', for which R(n) equals 8001 | |
findN n = | |
if rN n == 8001 | |
then n | |
else findN(n+1) | |
main = print (findN 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment