I found an unintuitive result, and I'd like help understanding why this is the case. I was experimenting with the sequence given by $a_n = 1 + \frac{1}{a_{n-1}}, a_1 = 1$. This sequence goes like $1, 2, \frac{3}{2}, \frac{5}{3}, \frac{8}{5}, \frac{13}{8}...$ and produces a Fibonacci-esque relation between the numerators and denominators.
Now, I tried writing the similar sequence $b_n = 1 + (b_{n-1})^{-1} mod 13$, where the $^{-1}$ denotes the modular inverse. $b_1 = 1$ as well, so the sequence goes $1, 1 + 1 = 2, 1 + 7 = 8, 1 + 5 = 6, 1 + 11 = 12, 1 + 12 = 0$.
If you compare the two sequences, $b_n$ hits 0 at the same time the numerator of $a_n$ hits 13, which is 0 mod 13. My question is, why does this happen? The intuitive result in my mind is that if $b_n = 0$ and $a_n = \frac{p}{q}$, then the conclusion wouldn't be that the numerator of $p$ is divisible by 13, but rather that $p * (q)^{-1}$ would be divisible by 13, where $q^{-1}$ is the modular inverse of $q$ mod 13, as you would convert the whole fraction to mod 13.
So anyway, my question is, is there an intuitive way of understanding why just the numerator is the one that will be divisible mod 13, rather than the entire fraction $a_n$?