Write a program to print the sum of the squares of all the numbers from 1 to 10 using a loop.
Answers
Answered by
0
Answer:
Using the J programming language:
Find the even numbers from 1 to 20, square them, then store all the the squares in a, & list them:
]a=.*:ev 1 to 20
4 16 36 64 100 144 196 256 324 400
Now reverse the order of the odd integers in a, and add them, showing partial sums in the process:
+/"1+\|.a
400 724 980 1176 1320 1420 1484 1520 1536 1540
So the final sum of the squares of the even integers is 1540,
Similar questions