Frobenius coin problem | Utility function to find gcd ; Function to print the desired output ; Solution doesn 't exist   if GCD is not 1 ; Else apply the formula ; Driver Code
< ? php function gcd ( $ a , $ b ) { $ c ; while ( $ a != 0 ) { $ c = $ a ; $ a = $ b % $ a ; $ b = $ c ; } return $ b ; } function forbenius ( $ X , $ Y ) { if ( gcd ( $ X , $ Y ) != 1 ) { echo " NA STRNEWLINE " ; return ; } $ A = ( $ X * $ Y ) - ( $ X + $ Y ) ; $ N = ( $ X - 1 ) * ( $ Y - 1 ) / 2 ; echo " Largest Amount = " , ▁ $ A , ▁ " " ; STRNEWLINE TABSYMBOL echo ▁ " Total Count = " , ▁ $ N , ▁ " " } $ X = 2 ; $ Y = 5 ; forbenius ( $ X , $ Y ) ; $ X = 5 ; $ Y = 10 ; echo " STRNEWLINE " ; forbenius ( $ X , $ Y ) ; ? >