Find N digits number which is divisible by D | CPP program to Find N digits number which is divisible by D ; Function to return N digits number which is divisible by D ; to store answer ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; string findNumber ( int n , int d ) { string ans = " " ; if ( d != 10 ) { ans += to_string ( d ) ; for ( int i = 1 ; i < n ; i ++ ) ans += '0' ; } else { if ( n == 1 ) ans += " Impossible " ; else { ans += '1' ; for ( int i = 1 ; i < n ; i ++ ) ans += '0' ; } } return ans ; } int main ( ) { int n = 12 , d = 3 ; cout << findNumber ( n , d ) ; return 0 ; }