text: Check if it is possible to reach ( X , Y ) from ( 1 , 0 ) by given steps | Function to find the GCD of two numbers a and b ; Base Case ; Recursively find the GCD ; Function to check if ( x , y ) can be reached from ( 1 , 0 ) from given moves ; If GCD is 1 , then print " Yes " ; Given X and Y ; Function call
code: function GCD ( a , b ) { if ( b == 0 ) return a ; else return GCD ( b , a % b ) ; } function check ( x , y ) { if ( GCD ( x , y ) == 1 ) { document . write ( " " ) ; } else { document . write ( " " ) ; } } let X = 2 , Y = 7 ; check ( X , Y ) ;