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 pr " Yes " ; Driver Code ; Given X and Y ; Function call
def GCD ( a , b ) : NEW_LINE INDENT if ( b == 0 ) : NEW_LINE INDENT return a NEW_LINE DEDENT else : NEW_LINE INDENT return GCD ( b , a % b ) NEW_LINE DEDENT DEDENT def check ( x , y ) : NEW_LINE INDENT if ( GCD ( x , y ) == 1 ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT X = 2 NEW_LINE Y = 7 NEW_LINE check ( X , Y ) NEW_LINE DEDENT