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
Jelentkezz be a beküldési előzmények megtekintéséhez
BejelentkezésJelentkezz be az MI-mentor használatához
BejelentkezésVisible tests
1
Input
1Expected
True2
Input
3Expected
True3
Input
6Expected
True4
Input
10Expected
True5
Input
55Expected
True6
Input
4Expected
FalseFocus radio
Paused · SomaFM · Fluid