Co | Utility function ; function to check if pair is co - prime or not ; function to find and prlet co - prime pair ; Driver code
function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } function coprime ( a , b ) { return ( __gcd ( a , b ) == 1 ) ; } function pairSum ( n ) { let mid = Math . floor ( n / 2 ) ; for ( let i = mid ; i >= 1 ; i -- ) { if ( coprime ( i , n - i ) == true ) { document . write ( i + " " + ( n - i ) ) ; break ; } } } let n = 11 ; pairSum ( n ) ;