Function to find the largest number smaller than or equal to N that is divisible by k
< ? php function findNum ( $ N , $ K ) { $ rem = $ N % $ K ; if ( $ rem == 0 ) return $ N ; else return $ N - $ rem ; }