Find the nth Tetrahedral Number

Published by NedlohJ in

A tetrahedron is a pyramid with a triangular base and three sides. A tetrahedral number is a number of items within a tetrahedron.

Create a function that takes an integer n and returns the nth tetrahedral number.

Alternative Text

Examples

Tetra(2) ➞ 4

Tetra(5) ➞ 35

Tetra(6) ➞ 56

Notes

There is a formula for the nth tetrahedral number.

Watch a quick demo on how Edabit works.