One day an extremely bored student began writing down the positive integers in order: 1,2,3,... When she got to 20 she noticed that she had used the digit 1 twelve times (once each for 1,10,12,13,...,19 and twice for 11). She asked herself if there was some number n (greater than 1) such that in writing down the integers from 1 to n she would have used the digit 1 exactly n times.

Is there such an n?

If so, is there a largest such n?

What if the digit 1 is replaced by another digit?

What if we work in a number base other than base 10?