Count of m digit integers that are divisible by an integer n | Returns count of m digit numbers having n as divisor ; generating largest number of m digit ; generating largest number of m - 1 digit ; returning number of dividend ; Driver code
< ? php function findCount ( $ m , $ n ) { $ num1 = 0 ; for ( $ i = 0 ; $ i < $ m ; $ i ++ ) $ num1 = ( $ num1 * 10 ) + 9 ; $ num2 = 0 ; for ( $ i = 0 ; $ i < ( $ m - 1 ) ; $ i ++ ) $ num2 = ( $ num2 * 10 ) + 9 ; return ( ( $ num1 / $ n ) - ( $ num2 / $ n ) ) ; } $ m = 2 ; $ n = 6 ; echo findCount ( $ m , $ n ) , " STRNEWLINE " ; ? >