Find number of diagonals in n sided convex polygon | Java function to find number of diagonals in n sided convex polygon ; driver code to test above function
public class Diagonals { static int numberOfDiagonals ( int n ) { return n * ( n - 3 ) / 2 ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . print ( n + " ▁ sided ▁ convex ▁ polygon ▁ have ▁ " ) ; System . out . println ( numberOfDiagonals ( n ) + " ▁ diagonals " ) ; } }