Sunday, August 14, 2011

Problem 16

prob16.hs Problem 16
Filename: prob16.hs
--2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
--
--What is the sum of the digits of the number 2^1000?

module Prob16
       where
         import Char
             
         answer = sum(map digitToInt(show (2^1000)))


syntax highlighted by Code2HTML, v. 0.9.1

No comments:

Post a Comment