Computer Science, asked by saliravindram, 1 year ago

write a C program to find sum of series 1^2 +2^2 +3^2...+n^2 for given n

Answers

Answered by maryjessicka
0
You can use the arithmetic formula for 1^2+2^2+3^2+...+n^2 = (n(n+1)(2n+1))/6

You can refer the same program what madakapoor10 was posted but the logic would be different.

Instead for loop you can assign an integer variable and substitute the formula.
Ex: int s = (n(n+1)(2n+1))/6 where n is the input value.

Here you can reduce the looping process and save time
Similar questions