Triangular Sum
A triangular number is made by adding all numbers from 1 to n, like building a staircase of dots where each new row is one dot longer. Write a function triangular that returns the sum 1 + 2 + ... + n. For n = 0, the sum is empty, so the answer should be 0.
Примеры
Ввод
0Вывод
0Ввод
1Вывод
1Ввод
3Вывод
6Нужно реализовать
def triangular(n: int) -> int:
Теги
math
Zaloguj się, aby zobaczyć historię rozwiązań
Zaloguj sięZaloguj się, aby korzystać z Mentora AI
Zaloguj sięVisible tests
1
Input
0Expected
02
Input
1Expected
13
Input
3Expected
64
Input
10Expected
555
Input
100Expected
50506
Input
7Expected
28Focus radio
Paused · SomaFM · Fluid