Friday, October 21, 2011

Big Integers in C#


Problem 13 in Project Euler(www.projecteuler.net) asks the participant to find the first 10 digits of the sum of fifty 100 digit numbers given. Most the trouble in doing this is finding something that can handle arithmetic on such large numbers. I knew that C# had a data type called BigInteger, which should be able to handle pretty much anything you throw at it. Made this one a Windows Form just for the hell of it. After that it was a simple read in the text file full of numbers into a text box, add them up, and then print out the first ten digits.

You can get the Visual Studio project file here. Contains source code and a runnable .exe:
http://www.sendspace.com/file/mic4n0

SPOILER ALERT: Answer is after the jump.

Answer is: 5537376230

No comments:

Post a Comment