The Nth Term of the Sequence

Published by Matt in

Write a function containing an expression, in terms of n, for the nth term of the sequence that has the following first six terms:

2, 6, 13, 23, 36, 52 ...and the sequence continues.

Examples

seq(1) ➞ 2

seq(2) ➞ 6

seq(6) ➞ 52

Notes

The parameter n is always >= 0.

Watch a quick demo on how Edabit works.