Project Euler

Project Euler Problem 48

steloflute 2012. 6. 9. 00:29

Problem 48

18 July 2003

The series, 11 + 22 + 33 + ... + 1010 = 10405071317.

Find the last ten digits of the series, 11 + 22 + 33 + ... + 10001000.


Answer:
9110846700

 

 

C#

 

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

namespace Euler {
    class Program {
        static void Main(string[] args) {
            Console.WriteLine(Enumerable.Range(1, 1000)
                .Select(x => Convert.ToInt64(BigInteger.ModPow(x, x, 10000000000).ToString()))
                .Sum() % 10000000000);
        }
    }
}



'Project Euler' 카테고리의 다른 글

Project Euler Problem 50  (0) 2012.06.09
Project Euler Problem 49  (0) 2012.06.09
Project Euler Problem 47  (0) 2012.06.09
Project Euler Problem 46  (0) 2012.06.09
Project Euler Problem 45  (0) 2012.06.09