Find a pair with sum N having minimum absolute difference | Java program to implement the above approach ; Function to find the value of X and Y having minimum value of Math . abs ( X - Y ) ; If N is an odd number ; If N is an even number ; Driver Code
import java . util . * ; class GFG { static void findXandYwithminABSX_Y ( int N ) { if ( N % 2 == 1 ) { System . out . print ( ( N / 2 ) + " ▁ " + ( N / 2 + 1 ) ) ; } else { System . out . print ( ( N / 2 - 1 ) + " ▁ " + ( N / 2 + 1 ) ) ; } } public static void main ( String [ ] args ) { int N = 12 ; findXandYwithminABSX_Y ( N ) ; } }