How do I get the sums of the digits of a large number in Haskell? -


I'm trying to teach myself a C ++ programmer Haskell and it's proving challenging to understand the basics of using functions as a form of loop, I have a large number, 50! And I have to add her points. This is a relatively easy loop in C ++ but I want to know how to do this in Haskell.

I have read some introductory guides and I am able to get 50!

sum50fac.hs ::

  ff 0 = 1 fac n = n fac (n -1) x = fac50 main = print x  

Unfortunately, at this point I am not completely sure how to reach the problem, it is possible to write a function that adds (MD) x 10 for one value and then again on x / 10 Does the function again call 10 less than 10? If this is not possible then how should I face this problem?

Thank you!

Why not just

  sumd = sum map Char.digitToInt shows  

Comments