60 525
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #18134 in AJAX | JavaScript | HTML | PHP for chetan

Question #18134
write a program to find the difference between sum of the squares and square of the sums of n numbers
Expert's answer
var n = prompt("Enter n");
if (n == '') {alert('Empty field!');}
else {
var sumOfSquare = 0;
var i;
for (i = 1; i <= n; i++) {
sumOfSquare += i*i;
}
var squareOfSum = n*(n+1)/2;
alert("Difference is " + (sumOfSquare - squareOfSum));
}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions