Largest number by which given 3 numbers should be divided such that they leaves same remainder | __gcd function ; function return number which divides these three number and leaves same remainder . ; We find the differences of all three pairs ; Return GCD of three differences . ; Driver Code
< ? php function gcd ( $ a , $ b ) { if ( $ a == 0 ) return $ b ; return gcd ( $ b % $ a , $ a ) ; } function sameRemainder ( $ a , $ b , $ c ) { $ a1 = ( $ b - $ a ) ; $ b1 = ( $ c - $ b ) ; $ c1 = ( $ c - $ a ) ; return gcd ( $ a1 , gcd ( $ b1 , $ c1 ) ) ; } $ a = 62 ; $ b = 132 ; $ c = 237 ; echo sameRemainder ( $ a , $ b , $ c ) ; ? >