Add Up to N

This is a classic warm-up for loops or for using the sum formula: add all numbers from 1 up to a given limit. Write summation, which takes n and returns the sum of all integers from 1 to n, inclusive. For example, for 8, you need to add 1 + 2 + ... + 8.

Примеры

Ввод
1
Вывод
1
Ввод
8
Вывод
36
Ввод
22
Вывод
253

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

def summation(n: int) -> int:

Теги

math
PostgreSQLv16

Itt jelenik meg a kód futtatásának eredménye

Visible tests
1
Input
1
Expected1
2
Input
8
Expected36
3
Input
22
Expected253
4
Input
100
Expected5050
5
Input
2
Expected3
6
Input
4
Expected10
Focus radio
Paused · SomaFM · Fluid