TITLE: If $2^{2017} + 2^{2014} + 2^n$ is a perfect square, find $n$.
QUESTION [6 upvotes]: If $2^{2017} + 2^{2014} + 2^n$ is a perfect square, find $n$.

My first shot would be to assume the perfect square is $2^{2018}$, but how would I prove that?  Even if it is, what is $n$?  All help is appreciated.

REPLY [3 votes]: If you want an answer then $(a+b)^2 = a^2 + 2ab + b^2$ should suggest an obvious answer by setting $a^2 = 2^{2014}; 2ab=2^{2017}; 2^n = c^2$.  
i.e $(2^{1007} + 2^{\frac n2})^2 = 2^{2014} + 2*2^{1007}*2^{\frac n2} + 2^n= 2^{2014} + 2^{1 + 1007 + \frac n2} + 2^n$.  We just have to solve for $1 + 1007 + \frac n2 = 2017$.  So $n = 2018$.
But is it the only solution?
Bear with me.
Let $m$ be any positive integer.  Let $m = \sum_{i=0}^k a_i2^i; a_i = \{0|1\}$ but its unique binary expansion.  
Claim: If $m$ has 3 or more non-zero terms in its binary expansion then $m^2$ has more than 3 non-zero terms in its binary expansion.
Proof:  Let $m = 2^a + 2^b + 2^c + \sum_{i= c+1}^k a_i 2^i; a < b < c$.  ($a$ may equal $0$. and $a_i; i > c$ may all be $0$.)  
Then $m = (1 + 2^{b'} + 2^{c'} + \sum_{i=c+1}^k a_i2^{i - a})2^a; c'= c-a;b'=b-a$
So $m^2 = [(1 + 2^{b'} + 2^{c'} + 2*2^{b'}2^{c'}+ 2^{2b'} + 2^{c'}) + 2(1 + 2^{b'} + 2^{c'})\sum_{i=c+1}^k a_i2^{i - a} + (\sum_{i=c+1}^k a_i2^{i - a})^2]2^{2a}$.
$= 2^a + 2^b + 2^c + 2^{1+b+c}  +2^{2b} + 2^{2c} +..... $.
Note all the later terms, if they exist, are larger than $2^{2c}$ so  $m^2$ has at least four non-zero  terms in its binary expansion.
Okay...
So $2^{2017} + 2^{2014} + 2^n = m^2$ has at most three non-zero terms in its expansion.  So $m$ has at most $2$ it its expansion.
So $m = 2^k$ or $m = 2^k + 2^j$.
$2^{2017} + 2^{2014} + 2^n = 2^{2k}$ is impossible.
And $2^{2017} + 2^{2014} + 2^n = (2^k + 2^j)^2 = 2^{2k} + 2*2^j*2^k + 2^{2k}$ has only $n = 2018$ for solution.
So $n = 2018$ is the only solution.