@saiha So, currently we have 19, now first step is 19/9=2. As for the first step, I am trying to calculate what is tenths digit for the 19th integer. Based on 19/9=2, we know that the 19th integer's tenths digit must be at least 2 but less than 3! After that, we use 19-2*9=1 to get the rest lower digits of 19th integer. Then since 1 is less than 9, and it indicates we have got out of from our for loop, the lowest digit is just 1. Generally, int count = n/dp[i] is used to calculate what digit value for the (i+1)-th digit of the n-th integer can be.