Determine the position of the third person on regular N sided polygon | C # implementation of the approach ; Function to find out the number of that vertices ; Another person can 't stand on  vertex on which 2 children stand. ; calculating minimum jumps from each vertex . ; Calculate sum of jumps . ; Driver code ; Calling function
using System ; using System . Collections . Generic ; class GFG { static int vertices ( int N , int A , int B ) { int position = 0 ; int minisum = int . MaxValue ; int sum = 0 ; for ( int i = 1 ; i <= N ; i ++ ) { if ( i == A i == B ) continue ; else { int x = Math . Abs ( i - A ) ; int y = Math . Abs ( i - B ) ; sum = x + y ; if ( sum < minisum ) { minisum = sum ; position = i ; } } } return position ; } public static void Main ( String [ ] args ) { int N = 3 , A = 1 , B = 2 ; Console . WriteLine ( " Vertex ▁ = ▁ " + vertices ( N , A , B ) ) ; } }