If $2^{2017} + 2^{2014} + 2^n$ is a perfect square, find $n$.

$(2^x+2^y)^2=2^{2x}+2^{x+y+1}+2^{2y}$ so we can take $y=1007$ and $x=1009$ to conclude $2^{2018}+2^{2017}+2^{2014}$ is a square.


how to obtain all $n$:

$9(2^{2014})=2^{2017}+2^{2014}=k^2-2^n$.

Notice that we must have $k^2\equiv 1 \bmod 3$ implying $2^n\equiv 1\bmod 3$.

So $n=2m$.

From here we have $2^{2014}\times 9= (k+2^m)(k-2^m)=z(z+2^{m+1})$

there are now two cases, case one is when $z=9(2^j)$ and case two is when $z=2^j$

the first case is impossible because the number $9$ in binary is $1001$ and adding a power of two clearly wont make it a power of $2$. The other case is clearly only solved by taking $z=2^{1007}$ and taking $m=1009$ thus getting $z(z+2^{m+1})=2̣^{1007}(2^{1007}+2^{1010})=9(2^{2014})$.

So we need $n=2(1009)=2018$


The square is $$(2^{1007}+2^{1009})^2=2^{2014}+2^{2017}+2^{2018}$$

The answe is therefore $n=2018$


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.