Just for fun, I began to play with numbers of two distinct ciphers. I noticed that most of the cases if you consider the numbers $AB$ and $BA$ (written in base $10$), these have few common divisors: for example $13$ and $31$ are coprime, $47$ and $74$ are coprime. Obviously this is not always the case, because one can take non-coprime ciphers, however I realized that, for $0 \le a<b \le 9$, the quantity $$\gcd (10a+b, 10b+a)$$ is never too big. Using brute force I computed $$\max \{ \gcd (10a+b, 10b+a) : 0 \le a<b \le 9\} = \gcd (48,84)=12$$
After that, I passed to an arbitrary base $n \ge 2$, and considered $$f(n)= \max \{ \gcd (an+b, bn+a) : 0 \le a<b \le n-1 \}$$ For example $f(2)=1$ and $f(3)=2$.
Considering $n \ge 4$, I noticed that, picking $a=2, b=n-3$ we have $$2n+(n-3) = 3(n-1)$$ $$(n-3)n+2 = (n-2)(n-1)$$ so that $f(n)$ has a trivial lower bound $$(n-1) \le \gcd (2n+(n-3), (n-3)n+2) \le f(n) $$ (which holds for $n=2,3$ as well).
A second remark is $$\gcd (0n+b, bn+0) = b \le n-1$$ so that we can restrict ourselves to the case $a \neq 0$: in other words $$f(n)=\max \{ \gcd (an+b, bn+a) : 1 \le a<b \le n-1 \}$$
I wrote a very simple program which computes the value of $f(n)$ for $n \le 400$, selecting those numbers such that $f(n)=n-1$. Surprisingly, I found out that many numbers appeared: $$4, 6, 12, 18, 30, 42, 60, 72, 102, 108, 138, 150, 180, 192, 198, 228, 240, 270, 282, 312, 348$$
More surprisingly these turned out to be the numbers between couples of twin primes! What is going on here?