Q:

Write a JavaScript program to compute the sum of cubes of all integer from 1 to a given integer

0

Write a JavaScript program to compute the sum of cubes of all integer from 1 to a given integer.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

function sum_Of_Cubes(n) {
  var sumn = 0;

  for (var i = 1; i <= n; i++) {
    sumn += Math.pow(i, 3);
  }
  return sumn;
}

console.log(sum_Of_Cubes(3));
console.log(sum_Of_Cubes(4));

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now