k.go 345 B

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