Find two numbers with given sum and maximum possible LCM | Function that print two numbers with the sum X and maximum possible LCM ; variables to store the result ; If X is odd ; If X is even ; If floor ( X / 2 ) is even ; If floor ( X / 2 ) is odd ; Print the result ; Given Number ; Function call
function maxLCMWithGivenSum ( X ) { let A , B ; if ( X & 1 ) { A = X / 2 ; B = X / 2 + 1 ; } else { if ( ( X / 2 ) % 2 == 0 ) { A = X / 2 - 1 ; B = X / 2 + 1 ; } else { A = X / 2 - 2 ; B = X / 2 + 2 ; } } document . write ( A + " " + B + " " ) ; } let X = 30 ; maxLCMWithGivenSum ( X ) ;