Odd Triangle Row Sum

Odd numbers can be arranged into a neat triangle: the first row has one number, the second has two, the third has three, and so on. Write row_sum_odd_numbers, which takes a row number n and returns the sum of all numbers in that row. For example, row 2 contains 3 and 5, so its sum is 8.

Примеры

Ввод
1
Вывод
1
Ввод
2
Вывод
8
Ввод
13
Вывод
2197

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

def row_sum_odd_numbers(n: int) -> int:

Теги

math
PostgreSQLv16

Ovdje će se prikazati rezultat izvršavanja koda

Visible tests
1
Input
1
Expected1
2
Input
2
Expected8
3
Input
13
Expected2197
4
Input
42
Expected74088
5
Input
5
Expected125
6
Input
-100
Expected-1000000
Focus radio
Paused · SomaFM · Fluid