Heptagonal number | C ++ program to find the nth Heptagonal number ; Function to return Nth Heptagonal number ; Drivers Code
#include <iostream> NEW_LINE using namespace std ; int heptagonalNumber ( int n ) { return ( ( 5 * n * n ) - ( 3 * n ) ) / 2 ; } int main ( ) { int n = 2 ; cout << heptagonalNumber ( n ) << endl ; n = 15 ; cout << heptagonalNumber ( n ) << endl ; return 0 ; }