Print a number containing K digits with digital root D | Function to find a number ; If d is 0 k has to be 1 ; Print k - 1 zeroes ; Driver code
< ? php function printNumberWithDR ( $ k , $ d ) { if ( $ d == 0 && $ k != 1 ) echo " - 1" ; else { echo $ d ; $ k -- ; while ( $ k -- ) echo "0" ; } } $ k = 4 ; $ d = 4 ; printNumberWithDR ( $ k , $ d ) ; ? >