# Prove that if $x$ is divisible by $4$, then $x=a^2-b^2$ [duplicate]

If $x\in Z$ and divisible by $4$, then there are existing $a,b \in Z$ , so: $x=a^2-b^2$

I had been trying to figure out which way this should be solved. First I found out that if $x=20$, then $a^2 = 6^2$ and $b^2 = 4^2$ (of course $20=36-16$ ).

now I'm not sure if i could place those examples as an answer, or I need to prove it with some "proving tricks". anyway, I thought about that $a^2 - b^2 = (a+b)(a-b)$ and $4\mid x$ is also $x=4k$ for some $k$ integer.

• Definitely need some "proving tricks". Examples don't really show anything. – G Tony Jacobs Nov 5 '17 at 13:45
• Consider what happens to $x=(a+b)(a-b)$ if I decide that $b=a+2$. Can you then find an $a$ that works? – Arthur Nov 5 '17 at 13:45
• I edited the title and problem statement: To say $x$ is divided by 4 means you're considering $y = x \div 4$. That's different from saying $x$ is divisible by 4. One is an operation and the other is a relation. – Matthew Leingang Nov 5 '17 at 13:47

If $x=4k$ for some $k$, then $x=(k+1)^2-(k-1)^2$.

• I see what happens there when you open the parentheses, you get 4k. But I couldn't understand the way you manage to know that you can place a and b as K+1 or K-1 – Ofek Pintok Nov 5 '17 at 14:17
• @OfekPintok I didn't know from the start. I tried a few things until I got the answer. – José Carlos Santos Nov 5 '17 at 14:21

As $a+b\pm(a-b)$ are even,

$a+b, a-b$ have the same parity

Case$\#1:$ If $a+b$ is even, so will be $a-b\implies(a+b)(a-b)$ must be divisible by $4$

Let $(a+b)(a-b)=4m\iff\dfrac{a+b}2\cdot\dfrac{a-b}2=m$

If $m=pq,$ $\dfrac{a+b}2=p,\dfrac{a-b}2=q$

$\implies a=p+q, b=p-q$

Trivially choose $p$ or $q=1$

Case$\#2:$ If $a+b$ is odd, so will be $a-b\implies(a+b)(a-b)$ must be odd.

Let for odd $x(=uv),(a+b)(a-b)=uv$ where $u,v$ are odd

If $a+b=u,a-b=v;$

$a=\dfrac{u+v}2$ which is an integer as $u+v$ is even

$b=?$

Trivially set $u$ or $v=1$