Skip to content

Instantly share code, notes, and snippets.

@olegchir
Created November 17, 2016 22:13
Show Gist options
  • Save olegchir/dd3ca2a8016c32bbc85aac8ac5c4a6f5 to your computer and use it in GitHub Desktop.
Save olegchir/dd3ca2a8016c32bbc85aac8ac5c4a6f5 to your computer and use it in GitHub Desktop.
/**
* 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