Project Euler – Problem 48


Find the last ten digits of 1^1 + 2^2 + … + 1000^1000.

Problem:

The series, 1^(1) + 2^(2) + 3^(3) + … + 10^(10) = 10405071317.

Find the last ten digits of the series, 1^(1) + 2^(2) + 3^(3) + … + 1000^(1000).

My Solution:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Euler
{
    class Problem48 : IProblemBase
    {

        //The series, 1^(1) + 2^(2) + 3^(3) + ... + 10^(10) = 10405071317.

        //Find the last ten digits of the series, 1^(1) + 2^(2) + 3^(3) + ... + 1000^(1000).

        public Problem48()
        {
        }

        public string GetAnswer()
        {
            int limit = 1000;
            string result = string.Empty;

            for (int i = 1; i <= limit; i++)
            {
                result = Util.BigAdd(result, Util.BigPow2(i, i));
            }
            return result.Substring(result.Length - 10, 10);
        }

    }
}
Advertisements

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: