Find the nth Tetrahedral Number

Published by Evgeny SH 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.