Table of Contents
Introduction
The task to find and print the smallest M digit number divisible by N.
Program
def result(n, m): x = pow(10, m-1) if( x % n == 0): print(x) else: print((x + n) - ((x + n) % n)) n = 64 m = 8 result(n, m)
Output
Explanation
In the above code, we have taken the min M digit number as 10…M times. If min%N is equalled to zero, the min is returned otherwise we compute ((min+N) – ((min+N)%N)) and return the min value divisible by N.
0 Comments