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
Logáil isteach chun stair na n-aighneachtaí a fheiceáil
Logáil isteachLogáil isteach chun an Meantóir IS a úsáid
Logáil isteachVisible tests
1
Input
0, 3Expected
02
Input
3, 3Expected
63
Input
5, 4Expected
254
Input
2, 5Expected
55
Input
4, 5Expected
226
Input
3, 7Expected
18Focus radio
Paused · SomaFM · Fluid