Skip to content

Instantly share code, notes, and snippets.

@bencoveney
Last active August 29, 2015 14:04
Show Gist options
  • Save bencoveney/038a67cee71bcf24d28e to your computer and use it in GitHub Desktop.
Save bencoveney/038a67cee71bcf24d28e to your computer and use it in GitHub Desktop.
Large Sum
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
namespace EulerProject
{
class Program
{
// Constant Values
private const int numChars = 50;
[STAThread]
static void Main(string[] args)
{
cheat();
}
public static void cheat()
{
// Open a stream from the file
StreamReader streamReader = new StreamReader("TextFile1.txt");
// Read the lines from the file into char arrays
List<BigInteger> numberStrings = new List<BigInteger>();
string line;
while ((line = streamReader.ReadLine()) != null)
{
numberStrings.Add(BigInteger.Parse(line));
}
BigInteger result = new BigInteger();
numberStrings.ForEach(x => result += x);
System.Windows.Forms.Clipboard.SetText(result.ToString().Substring(0, 10));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment