Find conditions on $a, b, c$, and $d$ with $a\ne -1, 0, 1$ such that $d\mid(a^n+bn+c)$ for $n \ge 1$. This is a generalization of
Using induction, show that $4^n +15n - 1$ is divisible by $9$ for all $n \geq 1$
I want to find conditions on
$a, b, c$, and $d$
with
$a\ne -1, 0, 1$
such that
$d\mid(a^n+bn+c)$
for
$n \ge 1$.
Here is my result:
A sufficient condition
is that
$a+b+c \ne 0$
and
all of
$a+b+c,
b(a-1)$,
and
$c(a-1)-b$
are divisible by $d$.
For the problem
that prompted this,
with
$a=4, b=15, c=-1$,
these are
$18, 45,$
and
$-18$.
 A: First, let $$\gcd(a,d)=k$$therefore $$k|d|a^n+bn+c$$since $k|a$ we obtain$$k|bn+c$$ for any $n\ge 1$. This means that $$k|b+c\\k|2b+c$$so $$k|b\\k|c$$from which we can conclude that if $(a,b,c,d)$ is an answer, then so is $$\left({a',b',c',d'}\right)$$where$$a'={a\over \gcd(a,d)}\\b'={b\over \gcd(a,d)}\\c'={c\over \gcd(a,d)}\\d'={d\over \gcd(a,d)}$$which means that $\gcd(a,d)$. Therefore without loss of generality, we assume $\gcd(a,d)=1$ furthermore $d\in\Bbb N$ and solve the problem, i.e. find the 4-tuple $(a,b,c,d)$. All other answers can be found as $(ka,kb,kc,kd)$ for $k\in \Bbb Z$.
The case where $\gcd(a,d)=1$ and $d\in\Bbb N$
We show that there exists $p$ such that $1\le p\le d$ such that $$a^p\equiv 1\mod {d}$$
proof: first off, note that $$\Big\{a^k\mod d \ \Big|\ 1\le k\le d\Big\}\subseteq\Big\{1,2,\cdots ,d \Big\}$$ if such a $p$ doesn't exist, then we must have $i,j>i$ for which $$a^i\equiv a^j\mod d$$since $\gcd(a,d)=1$ we obtain $$a^{j-i}\equiv 1\mod d$$since $1\le j-i\le d$, this contradicts with our first assumption on non-existence of $p$ since we can choose $p=j-i$. This completes our proof.
Since such a $p$ exists, by substituting $n\to np$ in $d|a^n+bn+c$ we conclude that$$d|a^{np}+bnp+c$$therefore $$d|bnp+c+1$$for any $n\in\Bbb Z$. Also $$d|2bnp+c+1$$ by a simple argument we obtain $$d|c+1$$ which yields to $$d|a^n+bn-1$$for $n\in \Bbb Z$ and $\gcd(a,d)=1$.

Minor Conclusion
We have proved so far that
(1) if $\gcd(a,d)=1$ then $$d|a^n+bn+c\iff d|a^n+bn-1$$
(2) the case where $\gcd(a,d)\ne 1$ can be reduced to the case with $\gcd(a,d)=1$.

If $u$ is the smallest such that $$d|a^u-1$$ we easily conclude that $$d|bu$$ then an algorithm goes like this:

Choose $a,d$ such that $\gcd(a,d)=1$ and any $c$ with $d|c+1$. Then find $1\le u\le d$ such that $d|a^u-1$ (such a $u$ exists and is unique as proved before). Therefore for any $b$ with $d|bu$ and every $n\in \Bbb Z$ we have $$d|a^n+bn+c$$

We illuminate the result with some examples:
for $a=4,b=15,c=-1$, the condition $d|c+1$ is redundant since $c+1=0$. Also $\gcd(a,d)=1$ means all the odd values of $d$. Let $d=9$ then $$9|4^3-1$$ therefore $u=3$ and $$9|3b$$ which means that $b=3k$ for any $k\in\Bbb Z$. Now let $d=45$ therefore $$45|4^6-1$$and we have $$45|6b\to 15|b$$. Choosing $b=15$ satisfies both the examples.
