Created
November 17, 2016 22:16
-
-
Save olegchir/825aef1145ae126e8f1f9aaa2936a70c to your computer and use it in GitHub Desktop.
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
import java.math.BigInteger; | |
class Sum2 { | |
private static final BigInteger MIN = BigInteger.ONE; | |
private static final BigInteger MAX = new BigInteger("10000000000"); | |
private static final BigInteger TWO = new BigInteger("2"); | |
public static void main(String[] args) { | |
long start = System.nanoTime(); | |
final BigInteger result = (MIN.add(MAX)).multiply(MAX.divide(TWO)); //Hi from mister Gauss, motherfuckers! | |
long end = System.nanoTime(); | |
long microseconds = (end - start) / 1000; | |
System.out.println(String.format("Result: %s", result.toString())); | |
System.out.println(String.format("Execution time: %d", microseconds)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment