- 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 ).
1 Respuesta