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
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
1Expected
12
Input
8Expected
363
Input
5Expected
154
Input
100Expected
50505
Input
10Expected
556
Input
1000Expected
500500Focus radio
Paused · SomaFM · Fluid