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
PostgreSQLv16

Ovdje će se prikazati rezultat izvršavanja koda

Visible tests
1
Input
0
Expected0
2
Input
1
Expected1
3
Input
3
Expected6
4
Input
10
Expected55
5
Input
100
Expected5050
6
Input
7
Expected28
Focus radio
Paused · SomaFM · Fluid