Number of cycles formed by joining vertices of n sided polygon at the center | 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 ; Given N ; Function Call
function findCycles ( N ) { let res = 0 ; let finalResult = 0 ; let val = 2 * N - 1 ; let s = val ; res = ( N - 1 ) * ( N - 2 ) ; finalResult = res + s ; return finalResult ; } let N = 5 ; document . write ( findCycles ( N ) ) ;