Skip to content

Problem 16

November 14, 2009

The 16th problem of the project Euler site was fairly easy to solve.

With a one-line function, I am able to calculate the sum of the digits of 2x, for a given x as input:

import Char

sumF = sum . map digitToInt . show . (^) 2

Then, it was just a matter of calling the function with 1000 as input. The execution was really fast, so ghci presented (0.00 secs, 0 bytes).

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: