text: Megagon number | C ++ implementation for the above approach ; Function to find the nth Megagon Number ; Driver Code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; int MegagonNum ( int n ) { return ( 999998 * n * n - 999996 * n ) / 2 ; } int main ( ) { int n = 3 ; cout << MegagonNum ( n ) ; return 0 ; }