Centered hexagonal number | Program to find nth centered hexadecimal number . ; Function to find centered hexadecimal number . ; Formula to calculate nth centered hexadecimal number and return it into main function . ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int centeredHexagonalNumber ( int n ) { return 3 * n * ( n - 1 ) + 1 ; } int main ( ) { int n = 10 ; cout << n << " th ▁ centered ▁ hexagonal ▁ number : ▁ " ; cout << centeredHexagonalNumber ( n ) ; return 0 ; }