Program to print tetrahedral numbers upto Nth term | C ++ program to generate series of tetrahedral numbers ; function to print tetrahedral number series up to n ; loop to print series ; Calculate and print ith tetrahedral number ; Driver code ; function call to print series
#include <bits/stdc++.h> NEW_LINE using namespace std ; void printSeries ( int n ) { for ( int i = 1 ; i <= n ; i ++ ) { int num = i * ( i + 1 ) * ( i + 2 ) / 6 ; cout << num << " ▁ " ; } } int main ( ) { int n = 10 ; printSeries ( n ) ; return 0 ; }