2

Take two positive integers $a$ and $b$ that are not multiples of $5.$ Then, construct a list in the following fashion: let the first term be $5,$ and starting with the second number, each number is obtained by multiplying the previous number on the list by $a$ and adding $b.$ What is the maximum number of primes that the list can contain before obtaining the first composite number?


I first started the problem by writing out a couple terms in the sequence: $$5, 5a + b, 5a^2 + ab + b, 5a^3 + a^2b + ab + b, 5a^4 + a^3b + a^2b + ab + b, \cdots$$ I then tried interpreting each term in modulo $5$ but considering each $a, b \pmod{5}$ and expanding was far too long. Considering the terms in modulo $2$ also didn't work since there always exists a way to make the term $\not\equiv 0 \pmod{2}.$

Is there a better way to try and solve this problem besides grueling casework on $a,b, \pmod{5}$?

John Omielan
  • 52,653
questionasker
  • 1,171
  • 6
  • 20
  • Where did you get this problem? – Mike Jul 26 '22 at 00:23
  • A worksheet about modular arithmetic assigned in a class I'm taking. – questionasker Jul 26 '22 at 01:08
  • $ab+b=b(a+1)$ When is this a multiple of $5$? What about $a^2b+ab+b=b(a^2+a+1)$? – Daniel Mathias Jul 26 '22 at 01:35
  • Well, $b(a+1)$ is a multiple of $5$ when $a \equiv 4 \pmod{5}$ because neither $a,b$ can be multiples of $5,$ and $b(a^2 + a + 1)$ is never a multiple of $5$ because $a^2 + a + 1 \not \equiv 0 \pmod{5}.$ – questionasker Jul 26 '22 at 01:39
  • After repeatedly substituting the polynomials into WolframAlpha, it appears that $b(a^{19} + a^{18} + \cdots + a + 1)$ is divisible by $5$ for $a \equiv 1, 2, 3, 4 \pmod{5},$ but I am unsure how to prove this. – questionasker Jul 26 '22 at 01:44
  • I'm sorry I missed your replies. (You didn't tag @Daniel) What I was hinting at is $a^3+a^2+a+1\equiv 0\pmod{5}$ when $a\equiv 2\pmod{5}$ or $a\equiv 3\pmod{5}$ and $a^4+a^3+a^2+a+1\equiv 0\pmod{5}$ when $a\equiv 1\pmod{5}$ and this covers all values of $a$. – Daniel Mathias Jul 26 '22 at 02:43

2 Answers2

5

Note your sequence is a linear recurrence with constant coefficients, i.e.,

$$n_0 = 5, \; \; n_k = an_{k-1} + b \; \forall \; k \ge 1 \tag{1}\label{eq1A}$$

We could determine $n_k$ explicitly using the method specified in the link, but note instead that, for $a \not\equiv 1 \pmod{5}$, as can be seen from your list of initial values (& can be proven using induction), we have

$$n_k \equiv 5a^k + b\left(\frac{a^k-1}{a-1}\right) \pmod{5} \tag{2}\label{eq2A}$$

By Fermat's little theorem, $a^4 - 1 \equiv 0 \pmod{5}$, so $n_4 \equiv 0 \pmod{5}$. Since $n_4 \gt 5$, it's not a prime and, thus, there's a maximum possible $4$ primes in a row.

For $a \equiv 1 \pmod{5}$, we instead have

$$n_k \equiv 5 + kb \pmod{5} \tag{3}\label{eq3A}$$

Note that $n_k \not\equiv 0 \pmod{5}$ for $1 \le k \le 4$, but that $n_5 \equiv 5 + 5b \equiv 0 \pmod{5}$, so it's not a prime. This shows there's a maximum possible $5$ initial primes in a row. In particular, $a = 1$ and $b = 6$ give an initial list of $5$ primes of $\{5, 11, 17, 23, 29\}$. This proves that $5$ is the maximum initial number of primes in a row possible in your sequence.

John Omielan
  • 52,653
2

Though you've accepted an answer a day prior, it's worth strong emphasis that problems like this can be solved more simply (and more generally) using basic ideas about permutation cycles (if these are unfamiliar then see the alternative direct proof in a Remark below). Bringing to the fore the innate $\rm\color{#0a0}{periodic\, (cycle)}$ structure of the sequence $\!\bmod 5\,$ yields the very simple proof below.

Proof $\, $ Your sequence $\:\!c_n$ is generated by iteratively applying $\:\!f(x) = ax\:\!\!+\!b\,$ starting at $\,\color{}{c_0 = 5},\,$ i.e. $\,c_n = f^n(c_0).\,$ Viewed $\!\bmod 5\:\!$ note $f\,$ is invertible: $\,f^{-1}(x) \equiv (x\!-\!b)/a,\,$ by $\,a\not\equiv 0,\,$ so $f\,$ is a $\rm\color{#0a0}{permutation}$, and all $\:\!c_k\:\!$ lie in the $\:\!\rm\color{#0a0}{orbit\, ({\it cycle})}$ $f^k(\color{}{c_0})$ of length at most $\:\!\color{#c00}5 = |\Bbb Z_5|.\,$ So the initial value $\,c_0\equiv 0\pmod{\!5}\,$ repeats as $\,c_k\equiv 0\,$ for $\,0< k\le \color{#c00}5,\,$ so $\,5\mid c_k,\,$ so $\,c_k\,$ is composite (by $c_k$ is increasing so $\,k>0\Rightarrow c_k> c_0\!=\!5).\,$ Thus there are at most $\,\color{#c00}5\,$ initial primes in $\,c_k.\ \ \small\bf QED$


Remark $ $ If permutation cycles are unknown then we can directly prove the needed $\rm\color{#0a0}{periodicity}$.

Lemma $ $ If $f$ is an invertible map on $\Bbb Z_n = \Bbb Z \bmod n$ then $f^k(a)\equiv a\pmod{\! n}\,$ for some $\,k\le n$.

Proof $\, $ Pigeonhole $\Rightarrow$ among the $\,n\!+\!1\,$ values $\,a,f(a),f^2(a),\cdots, f^n(a)\,$ two are congruent, so for some $\,0\le i< j\le n\!:$ $\,f^j(a)\equiv f^i(a)\,$ so $f^{j-i}(a)\equiv a\,$ by: $ $ ($i$ times) apply $f^{-1}$ (to cancel $f^i)$.


Notice this approach does not require solving the recurrence (in closed form). Rather, we only need to prove that the function $f\:\!$ generating the recurrence is invertible. Then we may apply a fundamental fact - that the cycle graph of an invertible map on a finite set consists of purely periodic cycles, i.e. shape oh (o) vs. rho ($\rho$), i.e. no preperiod part as in the initial tail of the rho. This basic result is often overlooked, leading to unnecessarily complex proofs - which essentially amount to reinventing the wheel (cycle). See here for further discussion and examples, including some nonlinear recurrences.

Bill Dubuque
  • 282,220