← Back to challenges

Find the nth Tetrahedral Number

PythonHardmathnumberslogic

Instructions

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.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Max Adjacent Product