Write an algorithm to compute sum of the square of N numbers.
Answers
Answered by
12
Explanation:
Examples :
Input : n = 2
Output : 5
Explanation: 1^2+2^2 = 5
Input : n = 8
Output : 204
Explanation :
1^2 + 2^2 + 3^2 + 4^2 + 5^2 + 6^2 + 7^2 + 8^
Answered by
46
Write an algorithm to compute sum of the square of N numbers.
Explanation:
Algorithm to compute sum of the square of N numbers.
[SumOfSquare procedure: Input integer n from user, set sum=0 and calculate sum.]
Step 1. Start
Step 2. Read number n
Step 3. Initialize
sum=0, i=1
Step 4. Repeat step 4 through 6 until i<=n
Step 5. Calculate
sum=sum+(i*i)
Step 6. increment i
i=i+1
Step 7. print the sum of square "sum"
Step 8. stop
[end of loop step 4]
[end of SumOfSquare procedure]
Similar questions