Simple Row Sum

Published by Werdna in

Imagine this triangle:

    1
   2 3
  4 5 6
 7 8 9 10
...

Create a function which takes a number n and returns the sum of all numbers in nth row.

Examples

rowSum(1) ➞ 1

rowSum(2) ➞ 5

rowSum(4) ➞ 34

Notes

1 <= N <= 1000

Watch a quick demo on how Edabit works.