Python problem | SoloLearn: Learn to code for FREE!

-1

Python problem

Write a program that takes a positive integer as input, and prints the alternating sum of the squares of the integers from 1 to the given input number. The alternating sum of squares of the first n integers is 1^2 − 2^2 + 3^2 − 4^2 + 5^2 + ...n^2 . For example, if the input is 1, the output must be 1 (because 1^2 = 1 ). If the input is 2, the output must be -3 (because 1^2 − 2^2 = − 3 ). If the input is 3, the output must be 6 (because 1^2 − 2^2 + 3^2 = 6 ). If the input is 4, the output must be -10 (because 1^2 − 2^2 + 3^2 − 4^2 = − 10 ).

6/27/2020 9:03:54 AM

Christian Velarde

1 Answer

New Answer

+4

Christian Velarde Please don't give challenges,homeworks or Assignments here QnA forum is only limited to programming related queries or Sololearn issues Now plz move this question to your activity feed or show your atttempt for further help Follow our Guidelines:- https://www.sololearn.com/discuss/333866/?ref=app HaPpY CoDiNg 🙂