# Squares in the sequence $a3^n+b$

Let $a \in \mathbb{N}, b \in \mathbb{Z}$. Define $n$ to be the largest nonnegative integer such that the sequence $\{a_1, a_2, \ldots, a_n \}$ consists entirely of squares of natural numbers, where $a_n := a3^n+b$? For which values of $a,b$ does $n$ achieve a maximum value?

I managed to prove that the sequence is finite for any given $a,b$, but I have not gone further than this. I would be happy with any hint. Thank you

• Interesting question. Can you share your proof that the sequence is finite? I'm curious in particular whether your length bound can be made uniform in $a,b$ or whether it might be arbitrarily large depending on $a,b$. May 29 '18 at 17:50
• Let $$3^na+b = x^2, 3^{n+2}a+b = y^2$$ then $$4x^2-y^2 = (2x+y)(2x-y) = 3b \Rightarrow 2x+y \leq 3b$$ But for large $n$, the sum is $2x + y$ and unbounded May 29 '18 at 17:54
• How it seems to me that the answer is about $n = 10$ May 29 '18 at 17:57
• Ah very nice. For a stronger bound, I’m thinking this is fairly similar to the classical “no 4 squares in arithmetic progression” problem. I would guess that $(w^2-z^2) = 3(z^2-y^2)=9(y^2-x^2)$ gives rise to an elliptic curve that can be studied. Though if you have found any examples with $n>4$ then that would suggest something more is going on. May 29 '18 at 18:16
• $a=41860$ and $b=117469$ gives a chain of length $4$ Jun 8 '18 at 6:36

One can use both periodicity of powers of $3$ modulo $10$ and squares modulo ${10}$.
Put $A3^n+B=\square$ with $A\equiv a\pmod{10}$ and $B\equiv b\pmod{10}$. It follows
$a3^n+b\equiv c= 0,1,4,9,6,5\pmod{10}$ $$\begin{cases}a+b=10x+c\\3a+b=10y+c=10x+c+2a\\7a+b=10z+c=10x+c+5a\\9a+b=10w+c=10x+c+8a\end{cases}$$ By simple subtraction of second and third (or third and fourth) equations we get $a=0$.
Consequently one has to study the equations $$10x3^n+10y+c=z^2;\qquad c=0,1,4,9,6,5$$ or,equivalently, $$10x3^n+10y=(z-\sqrt c)(z+\sqrt c)$$ With the convenient fact that $\mathbb Q(\sqrt5)$ and $\mathbb Q(\sqrt6)$ are norm-Euclidean quadratic fields.