Smallest number with sum of digits as N and divisible by 10 ^ N | PHP program to find smallest number to find smallest number with N as sum of digits and divisible by 10 ^ N . ; If N = 0 the string will be 0 ; If n is not perfectly divisible by 9 output the remainder ; Print 9 N / 9 times ; Append N zero 's to the number so  as to make it divisible by 10^N ; Driver Code
< ? php function digitsNum ( $ N ) { if ( $ N == 0 ) echo "0 STRNEWLINE " ; if ( $ N % 9 != 0 ) echo ( $ N % 9 ) ; for ( $ i = 1 ; $ i <= ( $ N / 9 ) ; ++ $ i ) echo "9" ; for ( $ i = 1 ; $ i <= $ N ; ++ $ i ) echo "0" ; echo " STRNEWLINE " ; } $ N = 5 ; echo " The ▁ number ▁ is ▁ : ▁ " ; digitsNum ( $ N ) ; ? >