3 ms·
/*author: Gauss */ var n = 1000000000; var sum = n*(n+1)/2;
by waynecochran 13y ago
/*author: Gauss */
var n = 1000000000;
var sum = n*(n+1)/2;
- cgh 13y agoNot sure why you're mentioning this as it's in the SO question: "The correct answer can be calculated using 1 + 2 + ... + n = n(n+1)/2"