# Check if positive integer is a perfect square

Check if positive integer $a+2b+4$ is a perfect square if $a=\underbrace{4 4... 4}_{2n\text{ digits }}$ , $b=\underbrace{8 8... 8}_{n\text{ digits }}$ and $n$ is a positive integer.

$$a=4\cdot\frac{10^{2n}-1}{10-1},b=8\cdot\frac{10^n-1}{10-1}$$

After factoring: $$a+2b+4=4\left(\frac{10^{2n}-1}{10-1}+4\cdot \frac{10^n-1}{10-1}+1\right)$$

For $n=1,n=2$, $\frac{10^{2n}-1}{10-1}+4\cdot \frac{10^n-1}{10-1}+1$ is not a perfect square.

Is there a number $n$ such that $a+2b+4$ is a perfect square?

• That should be 4 (blah + 2bleh +1). A 2 not a 4. Nov 23, 2016 at 23:29
• n=1 yields 11+4+1 is a perfect square. You meant 11+2+1 is not a perfect square. 1111+22+1=1134 isn't either. Nov 23, 2016 at 23:34
• The last two digits of blah + 2bleh +1 are always 34. $(10x+k)^2=100x^2+2xk+k^2 \equiv 34 \mod 100$. I think you can show that can never happen. Nov 23, 2016 at 23:40
• Yes. Xxxxx 34 is even but not divisible by 4 so is never a perfect square. And 11111.......11+22222.....2 + 1= 1111.....1333333....33334. Nov 23, 2016 at 23:45
• Oops. It's 2b! Well for n=1 we have 44 + 16 + 4=64 IS a perfect square. Nov 23, 2016 at 23:48

Write $10^n=x$. Now you have
$$4\left(\frac{x^2-1}{9}+\frac{4x-4}{9}+\frac{9}{9}\right)=$$ $$4\frac19\left(x^2-1+4x-4+9\right)=\frac{4}{9}(x+2)^2=\left(\frac{2(x+2)}{3}\right)^2$$ So it's always a perfect square.
• So in fact the number is $66\cdots668^2$ with $n-1$ digits $6$. Nov 23, 2016 at 23:38
Let $x=11\cdots11$ with $n$ digits. Then \eqalign{ 10^n&=9x+1\cr a&=4x(10^n+1)=4x(9x+2)\cr b&=8x\cr a+2b+4&=36x^2+24x+4\cr &=(6x+2)^2\cr &=66\cdots668^2\ ,\cr} where $6$ occurs $n-1$ times.