Add Up to the Limit

This is a classic warm-up for loops or the sum formula: add every number from 1 up to a given limit. Write summation, which takes num and returns the sum of all integers from 1 to num, inclusive. For example, for 5, the result comes from 1 + 2 + 3 + 4 + 5.

Примеры

Ввод
1
Вывод
1
Ввод
8
Вывод
36
Ввод
5
Вывод
15

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

def summation(num: int) -> int:

Теги

math
PostgreSQLv16

Koodin suorituksen tulos näkyy tässä

Tests11
Visible tests
Piilotettu testi 7
Piilotettu testi 8
Piilotettu testi 9
Piilotettu testi 10
Piilotettu testi 11

They run when you press "Submit" — your whole solution is checked against them so you can't hard-code answers for the visible cases.

Focus radio
Paused · SomaFM · Fluid