## Project Euler #48

The problem states Find the last ten digits of 1^{1} + 2^{2} + … + 1000^{1000}.

*Answer*: **9110846700**

*Solution*: I started with C# built-in data types but soon I realized that I was exceeding the max value for the data types. Then I tried Microsoft.FSharp.Math.BigInt (FSharp.Core.dll) and was pretty straight forward.

*var lOutput = Enumerable .Range(1, 1000) .Aggregate(BigInt.Zero, (pX, pY) => pX + BigInt.Pow(new BigInt(pY), new BigInt(pY))); var lAnswer = lOutput % BigInt.Pow(new BigInt(10), new BigInt(10));*

*Time*: 465 ms

Advertisements

## Leave a Reply