Repeated subtraction among two numbers | Returns count of steps before one of the numbers become 0 after repeated subtractions . ; If y divides x , then simply return x / y . ; Else recur . Note that this function works even if x is smaller than y because in that case first recursive call exchanges roles of x and y . ; Driver code
< ? php function countSteps ( $ x , $ y ) { if ( $ x % $ y == 0 ) return floor ( ( ( int ) $ x / $ y ) ) ; return floor ( ( ( int ) $ x / $ y ) + countSteps ( $ y , $ x % $ y ) ) ; } $ x = 100 ; $ y = 19 ; echo countSteps ( $ x , $ y ) ; ? >