Centered Octagonal Number | Program to find nth centered octagonal number ; Centered octagonal number function ; Formula to calculate nth centered octagonal number & return it into main function . ; Driver Code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int cen_octagonalnum ( long int n ) { return ( 4 * n * n - 4 * n + 1 ) ; } int main ( ) { long int n = 6 ; cout << n << " th ▁ centered " << " ▁ octagonal ▁ number ▁ : ▁ " ; cout << cen_octagonalnum ( n ) ; cout << endl ; n = 11 ; cout << n << " th ▁ centered " << " ▁ octagonal ▁ number ▁ : ▁ " ; cout << cen_octagonalnum ( n ) ; return 0 ; }