wywise / Polygon_Diagonal

How many polygon in "n" ribs diagonal

Repository from Github https://github.comwywise/Polygon_DiagonalRepository from Github https://github.comwywise/Polygon_Diagonal

Polygon Diagonal

With this C++ code you can know how many polygon there is in your "n" ribs diagonal.
All you need to insert is "n" - the numbers of the diagonal ribs.

We can see that to calculate the numbers of polygon we use this formula:

Diagonals = 0.5 * n * (n - 3)

Why I did it?

I was in an interview, where they asked me "How many Diagonals does Octagon have?"
I remembered the function and decided to build a little program that calculates how many diagonals any size of polygon have.

About

How many polygon in "n" ribs diagonal


Languages

Language:C++ 100.0%