Add Up to the Limit

Write a function summation that takes a number num and returns the sum of all integers from 1 to num, inclusive. If num is 0, return 0. A for loop over range(...) and a variable for accumulating the sum will help.

Примеры

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

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

def summation(num: int) -> int:

Теги

math
PostgreSQLv16

Hawn jidher ir-riżultat tat-tħaddim tal-kodiċi

Tests11
Visible tests
Test moħbi 7
Test moħbi 8
Test moħbi 9
Test moħbi 10
Test moħbi 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