Number of cycles formed by joining vertices of n sided polygon at the center | C ++ program for the above approach ; Function to calculate number of cycles ; BigInteger is used here if N = 10 ^ 9 then multiply will result into value greater than 10 ^ 18 ; BigInteger multiply function ; Return the final result ; Driver code ; Given N ; Function Call
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findCycles ( int N ) { int res = 0 ; int finalResult = 0 ; int val = 2 * N - 1 ; int s = val ; res = ( N - 1 ) * ( N - 2 ) ; finalResult = res + s ; return finalResult ; } int main ( ) { int N = 5 ; cout << findCycles ( N ) << endl ; return 0 ; }