Blog

In JavaScript Print the Sum of 0 to 255
Posted on June 2, 2015 in Algorithms, JavaScript by Matt Jennings

Print the sum of 0 + 1 + 2 + 3 + .... + 255:

var sum = 0;
for(var 0 = 1; i < 256; i++) {
  sum += i;
}
console.log(sum);

 

Leave a Reply