Triangular Number Check

Triangular numbers are made by adding natural numbers in order: 1, 1 + 2, 1 + 2 + 3, and so on. The same idea can be written with the formula t(k) = k * (k + 1) / 2. Write a function is_triangular that checks whether n can be produced this way. Return True if n is triangular, otherwise return False.

Примеры

Ввод
1
Вывод
True
Ввод
3
Вывод
True
Ввод
6
Вывод
True

Нужно реализовать

def is_triangular(n: int) -> bool:

Теги

math
PostgreSQLv16

Šeit parādīsies koda izpildes rezultāts

Visible tests
1
Input
1
ExpectedTrue
2
Input
3
ExpectedTrue
3
Input
6
ExpectedTrue
4
Input
10
ExpectedTrue
5
Input
55
ExpectedTrue
6
Input
4
ExpectedFalse
Focus radio
Paused · SomaFM · Fluid