Created
November 17, 2016 22:13
-
-
Save olegchir/dd3ca2a8016c32bbc85aac8ac5c4a6f5 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
/** | |
* Created by olegchir on 18.11.2016. | |
*/ | |
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 startTime = System.currentTimeMillis(); | |
final BigInteger result = (MIN.add(MAX)).multiply(MAX.divide(TWO)); //Hi from mister Gauss, motherfuckers! | |
long endTime = System.currentTimeMillis(); | |
System.out.println(String.format("Result: %s", result.toString())); | |
System.out.println(String.format("Execution time: %d milliseconds", endTime - startTime)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment