<s>[INST] How to find k'th integer not divisible by n? Although this was a programming question I want the mathematical intuition behind it. So we were given two numbers $n$ and $k$. We were asked to find out $k{-th}$ number **not divisible** by $n$. For example, $n=3$ and  
    $k=7$.  
 If we see numbers $1$ to $12$. $$1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12$$ Then $3,6,9$ are divisible by $3$ so we remove it. So we are left with $1, 2, 4, 5, 7, 8, 10, 11$. Clearly the $7th$ number not divisible by $3$ is $10$. So answer is $10$. It turns out the answer is: 
$$k+⌊\tfrac{k-1}{n-1}⌋$$
I want the mathematical intuition behind this formula.
 [/INST] We need the $k^{th}$ integer not divisible by $n$.
At first, we list all the integers not divisible by $n$. We don't know the values of these integers yet.
$$1^{st}, 2^{nd}, 3^{rd}, ..., k^{th}$$
This list omits the integers divisible by $n$. We need to know exactly how many such integers are omitted to find the value of the $k^{th}$ integer.
Exactly one integer (which is divisible by n) is omitted after $(n-1)$ integers. So, we need to know how many groups of $(n-1)$ integers do we encounter before reaching the $k^{th}$ integer. In other words, we will try to count the number of blocks of $(n-1)$ integers up till the $(k-1)^{th}$ non-divisible integer. And, that number is $\lfloor \frac{k-1}{n-1} \rfloor$.
The point of confusion might be the appearance of $(k-1)$. Remember, we need to find the number of $(n-1)$ integer blocks before we reach the $k^{th}$ integer. Examples might shed some light upon this.
Take $k=6$ and $n=3$ first. (I'll be omitting the positional identifiers, such as 'st, 'nd, 'th, etc.)
$$1,2,|,3,4,|,5,6,|$$
The pipe symbols express the position of the omitted integers. If we take $\lfloor \frac{k}{n-1} \rfloor$, we count the integer after the $6^{th}$ as well, which we don't want. Hence, we take $\lfloor \frac{k-1}{n-1} \rfloor$, which counts the missing integers before the $6^{th}$.
For the next example, consider $k=6$ and $n=2$. The missing integers will be placed like this.
$$1,|,2,|,3,|,4,|,5,|,6,|$$
Again, to count the missing integers before the $6^{th}$, we are gonna check how many groups of $(2-1)$ we can make up till the $5^{th}$. Hence $\lfloor \frac{6-1}{2-1} \rfloor$.
</s>