1

For example, if we have $36$, is there an algorithm to determine that it may equal $10^2-8^2$? What if we blow up the number to something like $492709612098$? Can it be written as the difference of two squares? If so, how do we know?

Also, does it matter if the number in question has more or fewer factors?

EDIT: I WANT TO KNOW THE ALGORITHM, AND NOT WHETHER A NUMBER MAY BE WRITTEN AS SUCH. BASICALLY I WANT TO KNOW IF THERE IS AN ALGORITHM WHERE YOU CAN INPUT NUMBER $N$ AND GET THE ADDEND SQUARE NUMBER $X$.

user26486
  • 11,331
  • Maybe it's worth using the fact that $10^2-8^2 = (10+8)(10-8)$? Then you can look at the factors. – Lynn Jun 21 '15 at 22:53
  • 6
    Please, avoid the extensive use of uppercase in your requests. Some may consider it rude. – Dmoreno Jun 22 '15 at 01:32
  • 3
    I think the caps are uncalled for.. – hjhjhj57 Jun 22 '15 at 01:32
  • 3
    Not only are caps uncalled for, not only it is rude, your claim "I want to know the algorithm and not whether a number may be written as such" flatly contradicts the bolded part in your first paragraph. – guest Jun 22 '15 at 03:08
  • 1
    It also makes you sound like you don't care about the maths, just want a solution - which no one will appreciate. – Alec Teal Jun 22 '15 at 04:04

2 Answers2

4

Let N=ab then consider $a=c+d$ and $b=c-d$. Then $c=\frac{a+b}{2}$ and $d=\frac{a-b}{2}$ now $N=c^2-d^2$. So the only numbers that can't be written as the difference of two squares are of the form $2K$ where K is an odd number. So your number $492709612098$ can't be written as a difference of two squares because $492709612098=2*246354806049$

Here is the algorithm in pseudocode

1) Write the number in the form $n=a*b$ where either $a$ and $b$ are both even or $a$ and $b$ are both odd

2) set $c=\frac{a+b}{2}$ and $d=\frac{a-b}{2}$

3) Now $N=c^2-d^2$

RowanS
  • 1,086
  • See my edit. What is the ALGORITHM to determine the square number addend? – HyperLuminal Jun 22 '15 at 01:15
  • 4
    To slightly complement this answer: compute the remainder of $n$ mod 4. If that remainder is $2$, terminate the algorithm. If the remainder is $0$, write $n = 4k$, then $n = (k + 1)^2 - (k-1)^2$. Otherwise, $n$ is odd, so write it as $n = 2k + 1$, and we have $n = (k+1)^2 - k^2$ – jxnh Jun 22 '15 at 02:40
1

This might answer partially your needs. One option is using Pythagorean triples $(a,b,c)$ of the form $a^2+b^2=c^2$, there is a known formula to obtain those kind of triples. Here is the link to the explanation at the Wikipedia.

If you can generate a triple $(a,b,c)$, then you can obtain $a^2 = c^2-b^2$ or $b^2 = c^2-a^2$.

Indeed if you obtain one primitive Pithagorean triple $(a,b,c)$ such as $a^2+b^2=c^2$ then you got a whole family of Pythagorean triples $ \forall k\gt 1\,\ (ka,kb,kc)\ /$ $(ka)^2 + (kb)^2 = (kc)^2$.

iadvd
  • 8,875