TITLE: $(xyz)_b$ is divisible by $n$ if and only if $z+3y-4x$ is divisible by $n$
QUESTION [5 upvotes]: Determine all natural numbers $n > 1$ with the following property: there exists a base $b \geq 5$ such that any three digit-number $(xyz)_b$ is divisible by $n$ if and only if $z+3y-4x$ is divisible by $n$.

Suppose that $b$ is such a base for some $n$. Then $xb^2+yb+z \equiv z+3y-4x \pmod{n}$, so that $x(b^2+4)+y(b-3) \equiv 0 \pmod{n}$. How can we continue?

REPLY [4 votes]: Immediately, we only have
$$n\mid xb^2+yb+z\iff  n\mid z+3y-4x\qquad \text{for }0\le x,y,z\le b-1$$
and not necessarily a congruence in general.
Nevertheless, $1+3\cdot 1-4\cdot1=0$ implies that $n\mid 111_b=b^2+b+1$.
By a similar argument, $n\mid 104_b=b^2+4$ (note that $4$ is a valid digit), hence also $n\mid b-3$.
Then also $n\mid (b^2+b+1)-(b-3)(b+4)=13$.
The only candidates are $n=1$ and $n=13$.
$n=1$ trivially has the desired property for any $b$ (but is excluded per problem statement).
$n=13$ works as well if we pick $b=16$: As $(256x+16y+z)-(z+3y-4x)=13\cdot(20x+y)$, we even have $xyz_{13}\equiv z+3y-4x\pmod{13}$.