Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.IO;
- using System.Numerics;
- // requires digits.txt to be in the right place
- namespace Euler13
- {
- class Program
- {
- static BigInteger sum = 0;
- static void Main(string[] args)
- {
- using (StreamReader read = new StreamReader("C:\\Users\\tombu\\Desktop\\digits.txt")) // load the file into read
- {
- while (!read.EndOfStream) // scan the fine
- {
- string line = read.ReadLine(); // get each line
- BigInteger num;
- bool success = BigInteger.TryParse(line, out num); // try to turn it to a big integer and store in num
- sum += num; // find the sum
- }
- }
- Console.WriteLine(sum);
- Console.ReadLine();
- } // end of main
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment