Centered triangular number | C ++ Program to find the nth Centered Triangular number ; function for Centered Triangular number ; formula for find Centered Triangular number nth term ; Driver Code ; For 3 rd Centered Triangular number ; For 12 th Centered Triangular number
#include <iostream> NEW_LINE using namespace std ; int Centered_Triangular_num ( int n ) { return ( 3 * n * n + 3 * n + 2 ) / 2 ; } int main ( ) { int n = 3 ; cout << Centered_Triangular_num ( n ) << endl ; n = 12 ; cout << Centered_Triangular_num ( n ) << endl ; return 0 ; }