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
Prijavi se da vidiš povijest predaja
PrijavaPrijavi se da koristiš AI mentora
PrijavaVisible tests
1
Input
1Expected
12
Input
8Expected
363
Input
22Expected
2534
Input
100Expected
50505
Input
2Expected
36
Input
4Expected
10Focus radio
Paused · SomaFM · Fluid