Basic Formula: Number of diagonal in N-gon is (N * (N-3) ) / 2.
U are given the right portion of the equation, now u have to find the value of N.
Suppose, Given value X
N = ceil ( (3 + sqrt (9 + ( 8 * N))) /2); [ceil >>> under <math.h>]
This equation comes from:
( N * ( N-3 ) ) / 2 = X
> N2 – 3*N – 2*X = 0
We know, X = (– b + sqrt (b2 – 4 * a * c )) / 2 * a
In C/C++, u can print a double value like integer by using %0.lf.
For example, double X = 963.258;