For which integer $n$ is $28 + 101 + 2^n$ a perfect square? This question
For which integer $n$ is $$28 + 101 + 2^n$$ a perfect square. Please also suggest an algorithm to solve similar problems. Thanks
Btw, this question has been taken from an Aryabhatta exam for 8th graders in India. 
 A: Write:$$28 + 101 + 2^n =k^2$$
For $n$ odd the expresion $$28 + 101 + 2^n\equiv 2\pmod 3$$ so in this case there is no solution (since $k^2\equiv 0,1\pmod 3$)
So $n= 2m$ and we have $$129 = k^2-2^{2m} = (k-2^m)(k+2^m)$$
Since $k-2^m<k+2^m$ we have only this possibiltes
$129 = k+2^m$ and $1=k-2^m$ ($m=6$) 
or
$43 = k+2^m$ and $3=k-2^m$ (no solution)
A: One way is to notice that 
$28+101+2^n=128+1+2^n=2^7+1+2^n=2^n+2*2^6+1$. 
Therefore, if we let $n=12$ we have 
$2^{12}+2*2^6+1=(2^6)^2+2*2^6+1=(2^6+1)^2$
Which is a perfect square, as desired.
This relies on noticing this specific pattern, so doesn't lend itself to a general method. One could always guess and check.
A: You can move terms around to try to get things to look like a perfect square trinomial:
$(a + b)^2 = a^2 + 2ab + b^2$
Specifically, the special case where $a$ or $b$ is 1:
$(1 + b)^2 = 1 + 2 b + b^2$
Start by combining the constant terms, and notice that 128 is a power of 2:
$28 + 101 + 2^n = 1 + 128 + 2^n = 1 + 2 \cdot 2^6 + 2^n$ 
We can see that $(1 + 2^6)^2 = 1 + 2 \cdot 2^6 + (2^6)^2 = 1 + 2 \cdot 2^6 + 2^{12}$
I think the squaring binomials/perfect square trinomials is your best general approach.
But given that the question was multiple choice, guess and check would solve this particular problem quickly ;)
A: Let us assume $n=2k$ and $129+2^{2k}=p^2$
Then we get:
$$p^2-(2^k)^2=129$$
$$(p-2^k)(p+2^k)=129=1 \times 129=3 \times 43 $$
So we get:
$$p-2^k=1$$
$$p+2^k=129$$
Solving we get
$$2^k=64$$ $\implies$ $k=6$
hence $$n=12$$
The other way of resolving will not give you integer solution of $k$
