Vasu Balakrishnan’s Blog

Project Euler #16

leave a comment »

Problem: What is the sum of the digits of the number 21000?

Answer: 1366

Solution: I’d to use F# BigInt and my ToDigits() extension method from the previous post.

var lNum = BigInt.Pow(new BigInt(2), BigInt.FromInt32(1000));
var lAnswer = lNum.ToDigits().Sum();

Time: 12 ms

Advertisements

Written by nbvasu

May 15, 2009 at 3:20 pm

Posted in C#, Euler, General

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: