Print a number containing K digits with digital root D | C # implementation of the above approach ; Function to find a number ; If d is 0 k has to be 1 ; Print k - 1 zeroes ; Driver code
using System ; class GFG { static void printNumberWithDR ( int k , int d ) { if ( d == 0 && k != 1 ) Console . Write ( " - 1" ) ; else { Console . Write ( d ) ; k -- ; while ( k -- > 0 ) Console . Write ( "0" ) ; } } static public void Main ( ) { int k = 4 , d = 4 ; printNumberWithDR ( k , d ) ; } }