Co | CPP program to represent a number as sum of a co - prime pair such that difference between them is minimum ; function to check if pair is co - prime or not ; function to find and print co - prime pair ; driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; bool coprime ( int a , int b ) { return ( __gcd ( a , b ) == 1 ) ; } void pairSum ( int n ) { int mid = n / 2 ; for ( int i = mid ; i >= 1 ; i -- ) { if ( coprime ( i , n - i ) == 1 ) { cout << i << " ▁ " << n - i ; break ; } } } int main ( ) { int n = 11 ; pairSum ( n ) ; return 0 ; }