Figure Numbers

Polygonal numbers can be pictured as dots arranged into triangles, squares, and other shapes. Given the position num and the number of polygon sides sides, return the num-th polygonal number for that kind of shape. For example, when sides is 4, the sequence gives square numbers.

Примеры

Ввод
0, 3
Вывод
0
Ввод
3, 3
Вывод
6
Ввод
5, 4
Вывод
25

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

def polygonal_num(num: int, sides: int) -> int:

Теги

math
PostgreSQLv16

Aici va apărea rezultatul execuției codului

Visible tests
1
Input
0, 3
Expected0
2
Input
3, 3
Expected6
3
Input
5, 4
Expected25
4
Input
2, 5
Expected5
5
Input
4, 5
Expected22
6
Input
3, 7
Expected18
Focus radio
Paused · SomaFM · Fluid