@gautam-arya This formula works ONLY when we consider the range [1, 10^n]

For example how many times we write the digit 6 when we write from 1 to 10000

We have 4 zeros, so the answer would be 4 x 10^3 = 4000

In other cases (like the one you mentioned), we have to go in the traditional way.

Will try something more interesting..

How many times we write 0 if we write from 1 to 10000 ?