Square Sum Gap

In math, the order of operations can completely change the result: you can square each number first, or add the numbers first and then square the sum. Write a function sum_square_difference that finds the difference between the square of the sum and the sum of the squares for the first n natural numbers. For example, for numbers from 1 to 10, compare (1 + 2 + ... + 10)^2 with 1^2 + 2^2 + ... + 10^2.

Примеры

Ввод
1
Вывод
0
Ввод
10
Вывод
2640
Ввод
100
Вывод
25164150

Нужно реализовать

def sum_square_difference(n: int) -> int:

Теги

math
PostgreSQLv16

Hier erscheint das Ergebnis der Codeausführung

Visible tests
1
Input
1
Expected0
2
Input
10
Expected2640
3
Input
100
Expected25164150
4
Input
2
Expected4
5
Input
3
Expected22
6
Input
5
Expected170
Focus radio
Paused · SomaFM · Fluid