Knowing that $a_m = 2a_{m - 1}(a_{m - 1} + 1)$, find $n$ such that $a_1^2 + a_2^2 + \cdots + a_{m - 1}^2 + a_m^2 + n^2$ is a square number. Knowing that $$\large a_0 \in \mathbb Z \mid a_m = 2a_{m - 1}(a_{m - 1} + 1), \forall m \in \mathbb Z^+$$, find $n$ such that $$\large a_1^2 + a_2^2 + \cdots + a_{m - 1}^2 + a_m^2 + n^2$$ is a square number for $\forall m \in \mathbb Z^+$.


I'm not sure how to solve this problem. The solution might include mathematical induction and I don't know about it.
In general, this is not possible:
Assume there are $b_m\ge0$ with
$$a_1^2+\cdots +a_m^2+n^2=b_m^2.$$
For example, if $a_0=1$, we find $a_1=4$, so
$$b_1^2=16+n^2.$$
Then $16=b_1^2-n^2=(b_1+n)(b_1-n)$, where both factirs have same, hence even, parity. This allows only $b_1+n=8$, $b_1-n=2$, so necessarily $n=3$, $b_1=5$.
But $a_2=2a_1(a_1+1)=40$, and we'd need
$$b_2^2=a_1^2+a_2^2+n^2=1625,$$
which is not a square.
Above equation shown below:

$$\large a_1^2 + a_2^2 + \cdots + a_{m - 1}^2 + a_m^2 + n^2=p^2 \tag{1}$$

Equation $(1)$ has numerical solution:

For, $m=3$ and $a_1=1$ we get:

$$(a_1,a_2,a_3)=(1,4,40)$$

And, $(n,p)=(8,41)$

Hence,

$$1^2+4^2+40^2+8^2=41^2$$