Created
April 14, 2017 23:47
-
-
Save LuxXx/d87bdbcae06d006db76685b6090093be to your computer and use it in GitHub Desktop.
Project Euler - Problem 13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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