Let $a$ and $b$ be positive integers such that $a > b$. Professor Fernando told student Raul that if he calculated the number $A = a^2 + 4b + 1$, the result would be a perfect square. Raul, by mistake, swapped the numbers $a$ and $b$ and calculated the number $B = b^2 + 4a + 1$, which, by chance, is also a perfect square.

a) Show that $A = (a+1)^2$.

b) Find the numbers $a, b, A$, and $B$.

#
Solution

a) Note that

$$
a^{2}<A=a^{2}+4 b+1<a^{2}+4 a+1<(a+2)^{2}
$$

Thus, $A$ is a perfect square between the perfect squares $a^{2}$ and $(a+2)^{2}$, and therefore $A=(a+1)^{2}$.

b) From the previous item,

$$
a^{2}+4 b+1=A=(a+1)^{2}=a^{2}+2 a+1
$$

and thus $a=2 b$. Substituting into $B=b^{2}+4 a+1$, we get $B=b^{2}+8 b+1$. Note now that

$$
(b+1)^{2}=b^{2}+2 b+1<b^{2}+8 b+1=B<b^{2}+8 b+16=(b+4)^{2}
$$

That is, $B$ is a perfect square between the perfect squares $(b+1)^{2}$ and $(b+4)^{2}$. Thus, we have two possible cases: $B=(b+2)^{2}$ or $B=(b+3)^{2}$.

Case I: $B=(b+2)^{2}$. In this case, we would have

$$
b^{2}+4 b+4=(b+2)^{2}=B=b^{2}+8 b+1
$$

and therefore, $b=3/4$ would not be an integer.

Case II: $B=(b+3)^{2}$. In this case, we would have

$$
b^{2}+6 b+9=(b+3)^{2}=B=b^{2}+8 b+1
$$

and thus $b=4$ and $a=8$. Finally,

$$
A=8^{2}+4(4)+1=9^{2} \quad \text { and } \quad B=4^{2}+4(8)+1=7^{2}
$$