Position of a person diametrically opposite on a circle | Java implementation of the approach ; Function to return the required position ; Driver code
class Sol { static int getPosition ( int n , int m ) { if ( m > ( n / 2 ) ) return ( m - ( n / 2 ) ) ; return ( m + ( n / 2 ) ) ; } public static void main ( String args [ ] ) { int n = 8 , m = 5 ; System . out . println ( getPosition ( n , m ) ) ; } }