#K77982. Number of Diagonals in a Regular Polygon
Number of Diagonals in a Regular Polygon
Number of Diagonals in a Regular Polygon
Given a regular polygon with n vertices, a diagonal is a line segment connecting two vertices that are not adjacent. The task is to compute the number of distinct diagonals in the polygon.
The formula to compute the number of diagonals is given by:
For example, a triangle (n = 3) has 0 diagonals, a quadrilateral (n = 4) has 2 diagonals, and a pentagon (n = 5) has 5 diagonals.
inputFormat
The input consists of a single integer n (n ≥ 3) representing the number of vertices of the regular polygon. The input is provided via standard input.
outputFormat
Output a single integer that is the number of distinct diagonals in the polygon. The output should be sent to standard output.
## sample3
0