Skip to content

Problem 56: Maximum digital sum of a googol

September 11, 2010

In order to solve this problem, I just created a brute force algorithm in Haskell:

import List
import Char

result = maximum [g (a^b) | a <- [1..99], b <- [1..99]]
  where g = sum . map digitToInt . show

main = print $ result

The execution is pretty fast:

real 0m0.059s
user 0m0.055s
sys 0m0.003s
Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: