Tetrahedral Numbers | CPP Program to find the nth tetrahedral number ; Function to find Tetrahedral Number ; Driver Code
#include <iostream> NEW_LINE using namespace std ; int tetrahedralNumber ( int n ) { return ( n * ( n + 1 ) * ( n + 2 ) ) / 6 ; } int main ( ) { int n = 5 ; cout << tetrahedralNumber ( n ) << endl ; return 0 ; }