DEV Community

loading...

Discussion on: Project Euler #6 - Sum Square Difference

Collapse
crownedprinz profile image
Ademola John • Edited

Here is my Javascript Solution


function sumSquareDifference(n) {
  // Good luck!
  let a = 0,b=0,c=0;
  for(let i = 1;i<=n;i++){
    a+= (Math.pow(i,2));
    b+=i
  }
c=Math.pow(b,2)-a

console.log(a);
console.log(b);
  return c;
}