Your description difffers from the question you link to in that it goes ..., Z, AA, BA, CA, ... instead of ..., Z, AA, AB, AC, ...
A detail that both lists cleverly(?) disguise with dots.
Anyway, it is evident that in the intended output the last (or first?) letters should make a repeating pattern A, B, ..., Z, A, B, ...
Therefore it is clear that the remainder of $n$ modulo 26 can be used to determine this letter. That is, we write $n =26\, n' + r$ with $n'\in \mathbb N_0$ and $0\le r < 26$. Numbers with the same $n'$ have different $r$ values, hence it is sufficient to construct the remaining letters from $n'$ alone - by using the very same algorithm.
This has one little problem: After a while we would rach $n=0$ and output A repeatedly. Subtracting 1 in the first step takes care of the fact that the first 26 codes need no second letter at all. Fortunately, it also makes sure that $n=1$ produces A in the first place. (If you'd want to start with $n=0\mapsto A$, the subtracting of 1 should be step 3a).