Split N into two integers whose addition to A and B makes them equal | Function to calculate the splitted numbers ; Calculate X ; If X is odd ; No pair is possible ; Otherwise ; Calculate X ; Calculate Y ; Driver function
function findPair ( A , B , N ) { var X , Y ; X = N - B + A ; if ( X % 2 != 0 ) { document . write ( " " ) ; } else { X = X / 2 ; Y = N - X ; document . write ( X + " " + Y ) ; } } var A = 1 ; var B = 3 ; var N = 4 ; findPair ( A , B , N ) ;