Question bank › Math
Dsa Math Medium

Polygon Diagonal Count

You are tasked with calculating the number of diagonals in a polygon with n sides. The formula for calculating the number of diagonals in a polygon is D = n(n - 3) / 2. Your program should compute this for given values of n. Input Format: - A single integer n (3 ≤ n ≤ 100). Output Format: - Print the number of diagonals in the polygon. Example: Input: 5 Output: 5 (A polygon with 5 sides has 5 diagonals.)

Key concepts

mathgeometrycombinatorics

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.