text: Check if it is possible to reach ( X , Y ) from ( 1 , 0 ) by given steps | C # program for the above approach ; 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 " ; Driver Code ; Given X and Y ; Function call
code: using System ; class GFG { static int GCD ( int a , int b ) { if ( b == 0 ) return a ; else return GCD ( b , a % b ) ; } static void check ( int x , int y ) { if ( GCD ( x , y ) == 1 ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } public static void Main ( ) { int X = 2 , Y = 7 ; check ( X , Y ) ; } }