Skip to content

Instantly share code, notes, and snippets.

@LuxXx
Created April 14, 2017 23:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuxXx/d87bdbcae06d006db76685b6090093be to your computer and use it in GitHub Desktop.
Save LuxXx/d87bdbcae06d006db76685b6090093be to your computer and use it in GitHub Desktop.
Project Euler - Problem 13
package euler;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.math.BigInteger;
public class LongSum {
public static void main(String[] args) throws Throwable {
BufferedReader br = new BufferedReader(new FileReader(new File("numbers.txt")));
String line;
BigInteger sum = BigInteger.ZERO;
while((line = br.readLine()) != null) {
sum = sum.add(new BigInteger(line));
}
br.close();
System.out.println(sum.toString().substring(0,10));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment