1234567891011121314151617 |
- package kata
- /*
- 1 1 1^3
- 3 5 8 2^3
- 7 9 11 27 3^3
- 13 15 17 19 64 4^3
- 21 23 25 27 29 125 5^3
- First: 1, prev+2, prev+4, prev+6, prev+8...
- s(n) = n^3 ?
- => s(n-1) = n^3 -3*n^2+3*n-1
- */
- func RowSumOddNumbers(n int) int {
- return n*n*n
- }
|