Skip to content

Instantly share code, notes, and snippets.

@bonipart
Created February 11, 2012 16:05
Show Gist options
  • Save bonipart/1801422 to your computer and use it in GitHub Desktop.
Save bonipart/1801422 to your computer and use it in GitHub Desktop.
Problem 1 of 3, embed.ly challenge
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