If we have placed all the digits up to pos - 1 equal to their limit and currently we are placing a digit which is smaller than this position 's limit then we can place  0 to 9 at all the next positions  to make the number smaller than R
if ( f == 0 and i < lmt ) new_f = 1 ;