David W Parker - Developer

home

Project Euler #6

published on

In JavaScript:

(function(){
  var sumSq = 0, sqSum = 0, total = 0;
  for (var i = 1; i < 101; i++){
       sumSq += Math.pow(i,2);
       total += i;
  }
  sqSum = Math.pow(total, 2);
  document.write("Square of the Sums: ", sqSum, "<br />");
  document.write("Sum of the Squares: ", sumSq, "<br />");
  document.write("Difference: ", sqSum - sumSq);
})();

on GitHub

Questions? E-mail me: this domain AT gmail DOT com