text: Check if it is possible to reach ( X , Y ) from ( 1 , 1 ) by given steps | Function to find the gcd of two numbers ; Base case ; Recurse ; Function to print the answer ; GCD of X and Y ; If GCD is power of 2 ; Given X and Y ; Function call
code: function gcd ( a , b ) { if ( a < b ) { let t = a ; a = b ; b = t ; } if ( a % b == 0 ) return b ; return gcd ( b , a % b ) ; } function printAnswer ( x , y ) { let val = gcd ( x , y ) ; if ( ( val & ( val - 1 ) ) == 0 ) document . write ( " " ) ; else document . write ( " " ) ; } let x = 4 ; let y = 7 ; printAnswer ( x , y ) ;