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
Prijavi se da vidiš povijest predaja
PrijavaPrijavi se da koristiš AI mentora
PrijavaTests11
Visible tests
Skriveni test 7
Skriveni test 8
Skriveni test 9
Skriveni test 10
Skriveni test 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