text: Largest number that divides x and is co | Recursive function to return gcd of a and b ; Everything divides 0 ; base case ; a is greater ; function to find largest coprime divisor ; Driver Code
code: < ? php function gcd ( $ a , $ b ) { if ( $ a == 0 $ b == 0 ) return 0 ; if ( $ a == $ b ) return $ a ; if ( $ a > $ b ) return gcd ( $ a - $ b , $ b ) ; return gcd ( $ a , $ b - $ a ) ; } function cpFact ( $ x , $ y ) { while ( gcd ( $ x , $ y ) != 1 ) { $ x = $ x / gcd ( $ x , $ y ) ; } return $ x ; } $ x = 15 ; $ y = 3 ; echo cpFact ( $ x , $ y ) , " STRNEWLINE " ; $ x = 14 ; $ y = 28 ; echo cpFact ( $ x , $ y ) , " STRNEWLINE " ; $ x = 7 ; $ y = 3 ; echo cpFact ( $ x , $ y ) ; ? >