Smallest N digit number divisible by N | Java program for the above approach ; Function to find the smallest N - digit number divisible by N ; Find largest n digit number ; Find smallest n digit number ; If i is divisible by N , then print i and return ; ; Driver Code ; Given Number ; Function Call
import java . util . * ; class GFG { static void smallestNumber ( int N ) { int L = ( int ) ( Math . pow ( 10 , N ) - 1 ) ; int S = ( int ) Math . pow ( 10 , N - 1 ) ; for ( int i = S ; i <= L ; i ++ ) { if ( i % N == 0 ) { System . out . print ( i ) ; return ; } } } public static void main ( String [ ] args ) { int N = 2 ; smallestNumber ( N ) ; } }