To find three such numbers, that the sum or difference of any two of
them shall be a square number.
L. Flynn:X+Y, |X-Y|, X+Z, |X-Z|, Y+Z, |Y-Z| are all squares.
To find three such numbers, that the sum or difference of any two ofThat's an ambiguous "or". Does it mean that any number which is the
them shall be a square number.
sum or difference of two of the three numbers shall be a square, or does
it mean that it shall be true that either the sum or the difference
is a square?
In other words, if X and Y are two of the numbers and X > Y, is it
required that X+Y and X-Y are both squares, or only one of them?
--
L. Flynn:
To find three such numbers, that the sum or difference of any two of
them shall be a square number.
That's an ambiguous "or". Does it mean that any number which is the
sum or difference of two of the three numbers shall be a square, or does
it mean that it shall be true that either the sum or the difference
is a square?
In other words, if X and Y are two of the numbers and X > Y, is it
required that X+Y and X-Y are both squares, or only one of them?
--
On Friday, June 17, 2022 at 5:17:35 PM UTC-4, Mark Brader wrote:
L. Flynn:X+Y, |X-Y|, X+Z, |X-Z|, Y+Z, |Y-Z| are all squares.
To find three such numbers, that the sum or difference of any two ofThat's an ambiguous "or". Does it mean that any number which is the
them shall be a square number.
sum or difference of two of the three numbers shall be a square, or does
it mean that it shall be true that either the sum or the difference
is a square?
In other words, if X and Y are two of the numbers and X > Y, is it
required that X+Y and X-Y are both squares, or only one of them?
--
To find three such numbers, that the sum or difference of any two of
them shall be a square number. I'll post the solution from 1750 in a
week.
In article <0361098f-6745-426a-bf20-e86a100afaa2n@googlegroups.com>,
leflynn <leflynn@hotmail.com> wrote:
To find three such numbers, that the sum or difference of any two of
them shall be a square number. I'll post the solution from 1750 in a
week.
Easier problem: guess who solved it in 1750.
In article <0361098f-6745-426a...@googlegroups.com>,Unless one had an encyclopedic knowledge of 18th English speaking persons as a pool (or some set even more limited containing the name of the solver), I would not think guessing the name of the solver I am aware of would be easier than guessing the six
leflynn <lef...@hotmail.com> wrote:
To find three such numbers, that the sum or difference of any two ofEasier problem: guess who solved it in 1750.
them shall be a square number. I'll post the solution from 1750 in a
week.
-- Richard
On 18/06/2022 4:34 pm, leflynn wrote:
On Friday, June 17, 2022 at 5:17:35 PM UTC-4, Mark Brader wrote:For all X, Y, and Z in the range 0-1000 and none equal to the
L. Flynn:X+Y, |X-Y|, X+Z, |X-Z|, Y+Z, |Y-Z| are all squares.
To find three such numbers, that the sum or difference of any two ofThat's an ambiguous "or". Does it mean that any number which is the
them shall be a square number.
sum or difference of two of the three numbers shall be a square, or does >> it mean that it shall be true that either the sum or the difference
is a square?
In other words, if X and Y are two of the numbers and X > Y, is it
required that X+Y and X-Y are both squares, or only one of them?
--
other two, I found no solutions.
--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
On Saturday, June 18, 2022 at 2:55:02 PM UTC-4, Richard Tobin wrote:
In article <0361098f-6745-426a...@googlegroups.com>,Unless one had an encyclopedic knowledge of 18th English speaking persons as a pool (or some set even more limited containing the name of the solver),
leflynn <lef...@hotmail.com> wrote:
To find three such numbers, that the sum or difference of any two ofEasier problem: guess who solved it in 1750.
them shall be a square number. I'll post the solution from 1750 in a
week.
-- Richard
I would not think guessing the name of the solver I am aware of would be easier than guessing the six square roots.
On Saturday, June 18, 2022 at 12:33:44 PM UTC-4, Richard Heathfield wrote:
On 18/06/2022 4:34 pm, leflynn wrote:
On Friday, June 17, 2022 at 5:17:35 PM UTC-4, Mark Brader wrote:For all X, Y, and Z in the range 0-1000 and none equal to the
L. Flynn:X+Y, |X-Y|, X+Z, |X-Z|, Y+Z, |Y-Z| are all squares.
To find three such numbers, that the sum or difference of any two of >>> them shall be a square number.That's an ambiguous "or". Does it mean that any number which is the
sum or difference of two of the three numbers shall be a square, or does >> it mean that it shall be true that either the sum or the difference
is a square?
In other words, if X and Y are two of the numbers and X > Y, is it
required that X+Y and X-Y are both squares, or only one of them?
--
other two, I found no solutions.
--[Program as spoiler space]
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
using System;
using System.Collections.Generic;
namespace SquaresPuzzle
{
class SquaresPuzzle
{
private const int N = 1000;
static void Main()
{
List<int[]> numbers = new List<int[]>();
for (int n1 = 1; n1 <= N; n1++)
{
for (int n2 = 1; n2 < n1; n2++)
{
if (n1 % 2 == n2 % 2)
{
int n1Squared = n1 * n1;
int n2Squared = n2 * n2;
int m1 = (n1Squared + n2Squared) / 2;
int m2 = (n1Squared - n2Squared) / 2;
numbers.Add(new[] { m1, m2 });
}
}
}
Comparer comparer = new Comparer();
numbers.Sort(comparer);
for (int n = 1; n < numbers.Count; n++)
{
if (numbers[n][0] == numbers[n - 1][0])
{
int n1 = numbers[n - 1][1];
int n2 = numbers[n][1];
int[] number1 = new[] { n1, n2 };
int[] number2 = new[] { n2, n1 };
if (numbers.BinarySearch(number1, comparer) >= 0 || numbers.BinarySearch(number2, comparer) >= 0)
{
Console.WriteLine("{0}, {1}, {2}", numbers[n][0], n1, n2);
}
}
}
}
public class Comparer : IComparer<int[]>
{
public int Compare(int[] x, int[] y)
{
int result = x[0].CompareTo(y[0]);
if (result == 0)
{
result = x[1].CompareTo(y[1]);
}
return result;
}
}
}
}
The program comes up with:
434657, 150568, 420968
Please reply to ilanlmayer at gmail dot com
__/\__
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
On Saturday, June 18, 2022 at 11:55:09 PM UTC-4, Ilan Mayer wrote:
On Saturday, June 18, 2022 at 12:33:44 PM UTC-4, Richard Heathfield wrote: >>> On 18/06/2022 4:34 pm, leflynn wrote:
[Program as spoiler space]On Friday, June 17, 2022 at 5:17:35 PM UTC-4, Mark Brader wrote:For all X, Y, and Z in the range 0-1000 and none equal to the
L. Flynn:X+Y, |X-Y|, X+Z, |X-Z|, Y+Z, |Y-Z| are all squares.
To find three such numbers, that the sum or difference of any two of >>>>>> them shall be a square number.That's an ambiguous "or". Does it mean that any number which is the
sum or difference of two of the three numbers shall be a square, or does >>>>> it mean that it shall be true that either the sum or the difference
is a square?
In other words, if X and Y are two of the numbers and X > Y, is it
required that X+Y and X-Y are both squares, or only one of them?
--
other two, I found no solutions.
--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
using System;
using System.Collections.Generic;
namespace SquaresPuzzle
{
class SquaresPuzzle
{
private const int N = 1000;
static void Main()
{
List<int[]> numbers = new List<int[]>();
for (int n1 = 1; n1 <= N; n1++)
{
for (int n2 = 1; n2 < n1; n2++)
{
if (n1 % 2 == n2 % 2)
{
int n1Squared = n1 * n1;
int n2Squared = n2 * n2;
int m1 = (n1Squared + n2Squared) / 2;
int m2 = (n1Squared - n2Squared) / 2;
numbers.Add(new[] { m1, m2 });
}
}
}
Comparer comparer = new Comparer();
numbers.Sort(comparer);
for (int n = 1; n < numbers.Count; n++)
{
if (numbers[n][0] == numbers[n - 1][0])
{
int n1 = numbers[n - 1][1];
int n2 = numbers[n][1];
int[] number1 = new[] { n1, n2 };
int[] number2 = new[] { n2, n1 };
if (numbers.BinarySearch(number1, comparer) >= 0 || numbers.BinarySearch(number2, comparer) >= 0)
{
Console.WriteLine("{0}, {1}, {2}", numbers[n][0], n1, n2);
}
}
}
}
public class Comparer : IComparer<int[]>
{
public int Compare(int[] x, int[] y)
{
int result = x[0].CompareTo(y[0]);
if (result == 0)
{
result = x[1].CompareTo(y[1]);
}
return result;
}
}
}
}
The program comes up with:
434657, 150568, 420968
Please reply to ilanlmayer at gmail dot com
__/\__
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
Nice program. The solution found in 1750 was
Answered by Mr. C. Bumpkin . By a method of substitution , too tedious to insert , he finds 1873432 , 2399057 , 2288168 , the three numbers , answering the conditions of the question .
I did not realize that the name was an alias until prodded by Richard Tobin.
In article <t8n5da$2uq$1@dont-email.me>,
Richard Heathfield <rjh@cpax.org.uk> wrote:
Nice program. The solution found in 1750 wasto insert , he finds 1873432 , 2399057 , 2288168 , the three numbers ,
Answered by Mr. C. Bumpkin . By a method of substitution , too tedious
answering the conditions of the question .
I did not realize that the name was an alias until prodded by Richard Tobin.
Alias of whom?
It's widely quoted that Frederick the Great considered Euler a
"country bumpkin"
As far as I can see from the interwebs, Euler seems to have been the
first to give the minimum solution and a generating formula.
Nice program. The solution found in 1750 wasto insert , he finds 1873432 , 2399057 , 2288168 , the three numbers , >answering the conditions of the question .
Answered by Mr. C. Bumpkin . By a method of substitution , too tedious
I did not realize that the name was an alias until prodded by Richard Tobin.
Alias of whom?
In article <t8n5da$2uq$1...@dont-email.me>,https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.352.5649&rep=rep1&type=pdf
Richard Heathfield <r...@cpax.org.uk> wrote:
Nice program. The solution found in 1750 wasto insert , he finds 1873432 , 2399057 , 2288168 , the three numbers , >answering the conditions of the question .
Answered by Mr. C. Bumpkin . By a method of substitution , too tedious
I did not realize that the name was an alias until prodded by Richard Tobin.
Alias of whom?It's widely quoted that Frederick the Great considered Euler a
"country bumpkin" - presumably in German - but I have no information
on whether he was in the habit of answering mathematical questions in
the Ladies' Diary:
https://books.google.co.uk/books?id=PLQDyr3T6NQC&pg=PA19
The solution above had been discovered by Ozanam in 1691.
As far as I can see from the interwebs, Euler seems to have been the
first to give the minimum solution and a generating formula.
-- Richard
On Saturday, June 18, 2022 at 11:55:09 PM UTC-4, Ilan Mayer wrote:
On Saturday, June 18, 2022 at 12:33:44 PM UTC-4, Richard Heathfield wrote:
On 18/06/2022 4:34 pm, leflynn wrote:
On Friday, June 17, 2022 at 5:17:35 PM UTC-4, Mark Brader wrote:For all X, Y, and Z in the range 0-1000 and none equal to the
L. Flynn:X+Y, |X-Y|, X+Z, |X-Z|, Y+Z, |Y-Z| are all squares.
To find three such numbers, that the sum or difference of any two of >>> them shall be a square number.That's an ambiguous "or". Does it mean that any number which is the
sum or difference of two of the three numbers shall be a square, or does
it mean that it shall be true that either the sum or the difference
is a square?
In other words, if X and Y are two of the numbers and X > Y, is it
required that X+Y and X-Y are both squares, or only one of them?
--
other two, I found no solutions.
--[Program as spoiler space]
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
using System;
using System.Collections.Generic;
namespace SquaresPuzzle
{
class SquaresPuzzle
{
private const int N = 1000;
static void Main()
{
List<int[]> numbers = new List<int[]>();
for (int n1 = 1; n1 <= N; n1++)
{
for (int n2 = 1; n2 < n1; n2++)
{
if (n1 % 2 == n2 % 2)
{
int n1Squared = n1 * n1;
int n2Squared = n2 * n2;
int m1 = (n1Squared + n2Squared) / 2;
int m2 = (n1Squared - n2Squared) / 2;
numbers.Add(new[] { m1, m2 });
}
}
}
Comparer comparer = new Comparer();
numbers.Sort(comparer);
for (int n = 1; n < numbers.Count; n++)
{
if (numbers[n][0] == numbers[n - 1][0])
{
int n1 = numbers[n - 1][1];
int n2 = numbers[n][1];
int[] number1 = new[] { n1, n2 };
int[] number2 = new[] { n2, n1 };
if (numbers.BinarySearch(number1, comparer) >= 0 || numbers.BinarySearch(number2, comparer) >= 0)
{
Console.WriteLine("{0}, {1}, {2}", numbers[n][0], n1, n2);
}
}
}
}
public class Comparer : IComparer<int[]>
{
public int Compare(int[] x, int[] y)
{
int result = x[0].CompareTo(y[0]);
if (result == 0)
{
result = x[1].CompareTo(y[1]);
}
return result;
}
}
}
}
The program comes up with:
434657, 150568, 420968
Please reply to ilanlmayer at gmail dot com
__/\__Nice program. The solution found in 1750 was
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
Answered by Mr. C. Bumpkin . By a method of substitution , too tedious to insert , he finds 1873432 , 2399057 , 2288168 , the three numbers , answering the conditions of the question .
I did not realize that the name was an alias until prodded by Richard Tobin.
L. Flynn
On Sunday, June 19, 2022 at 9:40:03 AM UTC-4, Richard Tobin wrote:
In article <t8n5da$2uq$1...@dont-email.me>,https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.352.5649&rep=rep1&type=pdf
Richard Heathfield <r...@cpax.org.uk> wrote:
It's widely quoted that Frederick the Great considered Euler aNice program. The solution found in 1750 wasto insert , he finds 1873432 , 2399057 , 2288168 , the three numbers ,
Answered by Mr. C. Bumpkin . By a method of substitution , too tedious
answering the conditions of the question .
I did not realize that the name was an alias until prodded by Richard Tobin.
Alias of whom?
"country bumpkin" - presumably in German - but I have no information
on whether he was in the habit of answering mathematical questions in
the Ladies' Diary:
https://books.google.co.uk/books?id=PLQDyr3T6NQC&pg=PA19
The solution above had been discovered by Ozanam in 1691.
As far as I can see from the interwebs, Euler seems to have been the
first to give the minimum solution and a generating formula.
-- Richard
In particular, Landen used the pseudonyms Sir Stately Stiff, Peter Walton, Waltoniensis, C. Bumpkin, and Peter Puzzlem, who, collectively, proposed ten problems and answered seventeen.
On Sunday, June 19, 2022 at 7:57:23 AM UTC-4, leflynn wrote:
On Saturday, June 18, 2022 at 11:55:09 PM UTC-4, Ilan Mayer wrote:
On Saturday, June 18, 2022 at 12:33:44 PM UTC-4, Richard Heathfield wrote:
On 18/06/2022 4:34 pm, leflynn wrote:
On Friday, June 17, 2022 at 5:17:35 PM UTC-4, Mark Brader wrote:For all X, Y, and Z in the range 0-1000 and none equal to the
L. Flynn:X+Y, |X-Y|, X+Z, |X-Z|, Y+Z, |Y-Z| are all squares.
To find three such numbers, that the sum or difference of any two ofThat's an ambiguous "or". Does it mean that any number which is the >> sum or difference of two of the three numbers shall be a square, or does
them shall be a square number.
it mean that it shall be true that either the sum or the difference >> is a square?
In other words, if X and Y are two of the numbers and X > Y, is it >> required that X+Y and X-Y are both squares, or only one of them?
--
other two, I found no solutions.
--[Program as spoiler space]
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
using System;
using System.Collections.Generic;
namespace SquaresPuzzle
{
class SquaresPuzzle
{
private const int N = 1000;
static void Main()
{
List<int[]> numbers = new List<int[]>();
for (int n1 = 1; n1 <= N; n1++)
{
for (int n2 = 1; n2 < n1; n2++)
{
if (n1 % 2 == n2 % 2)
{
int n1Squared = n1 * n1;
int n2Squared = n2 * n2;
int m1 = (n1Squared + n2Squared) / 2;
int m2 = (n1Squared - n2Squared) / 2;
numbers.Add(new[] { m1, m2 });
}
}
}
Comparer comparer = new Comparer();
numbers.Sort(comparer);
for (int n = 1; n < numbers.Count; n++)
{
if (numbers[n][0] == numbers[n - 1][0])
{
int n1 = numbers[n - 1][1];
int n2 = numbers[n][1];
int[] number1 = new[] { n1, n2 };
int[] number2 = new[] { n2, n1 };
if (numbers.BinarySearch(number1, comparer) >= 0 || numbers.BinarySearch(number2, comparer) >= 0)
{
Console.WriteLine("{0}, {1}, {2}", numbers[n][0], n1, n2);
}
}
}
}
public class Comparer : IComparer<int[]>
{
public int Compare(int[] x, int[] y)
{
int result = x[0].CompareTo(y[0]);
if (result == 0)
{
result = x[1].CompareTo(y[1]);
}
return result;
}
}
}
}
The program comes up with:
434657, 150568, 420968
Please reply to ilanlmayer at gmail dot com
__/\__Nice program. The solution found in 1750 was
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
Answered by Mr. C. Bumpkin . By a method of substitution , too tedious to insert , he finds 1873432 , 2399057 , 2288168 , the three numbers , answering the conditions of the question .
I did not realize that the name was an alias until prodded by Richard Tobin.
L. FlynnRevised program:
using System;
using System.Collections.Generic;
namespace SquaresPuzzle
{
class SquaresPuzzle
{
private const int N = 3000;
static void Main()
{
List<int[]> numbers = new List<int[]>();
for (int n1 = 1; n1 <= N; n1++)
{
for (int n2 = 1; n2 < n1; n2++)
{
if (n1 % 2 == n2 % 2)
{
int n1Squared = n1 * n1;
int n2Squared = n2 * n2;
int m1 = (n1Squared + n2Squared) / 2;
int m2 = (n1Squared - n2Squared) / 2;
numbers.Add(new[] { m1, m2 });
}
}
}
Comparer comparer = new Comparer();
numbers.Sort(comparer);
for (int n = 0; n < numbers.Count; n++)
{
int m = n;
while (++m < numbers.Count && numbers[m][0] == numbers[n][0])
{
int n1 = numbers[n][1];
int n2 = numbers[m][1];
int[] number1 = new[] { n1, n2 };
int[] number2 = new[] { n2, n1 };
if (numbers.BinarySearch(number1, comparer) >= 0 || numbers.BinarySearch(number2, comparer) >= 0)
{
int n0 = numbers[n][0];
int divisor1 = FirstDivisor(n0);
int divisor2 = FirstDivisor(n1);
int divisor3 = FirstDivisor(n2);
if (divisor1 != divisor2 || divisor1 != divisor3)
{
Console.WriteLine("{0}, {1}, {2}", n0, n1, n2);
}
}
}
}
}
private static int FirstDivisor(int number)
{
if (number % 2 == 0)
{
return 2;
}
int root = (int) Math.Sqrt(number);
for (int n = 3; n <= root; n += 2)
{
if (number % n == 0)
{
return n;
}
}
return number;
}
public class Comparer : IComparer<int[]>
{
public int Compare(int[] x, int[] y)
{
int result = x[0].CompareTo(y[0]);
if (result == 0)
{
result = x[1].CompareTo(y[1]);
}
return result;
}
}
}
}
It produces 5 solutions (excluding solutions where all 3 numbers share a divisor), including the original one:
434657, 150568, 420968
733025, 418304, 488000
2399057, 1873432, 2288168
3911913, 1355112, 3788712
5320193, 589568, 1782032
As far as I can see from the interwebs, Euler seems to have been the
first to give the minimum solution and a generating formula.
In 1750, who else could it have been?
Richard Tobin:
As far as I can see from the interwebs, Euler seems to have been the
first to give the minimum solution and a generating formula.
Richard Heathfield:
In 1750, who else could it have been?
Well, Gauss was alive then. Elderly, though.
Well, Gauss was alive then. Elderly, though.
/The/ Gauss was born in 1777, making him (in 1750) more sort of
youngerly.
On Sunday, June 19, 2022 at 7:57:23 AM UTC-4, leflynn wrote:
On Saturday, June 18, 2022 at 11:55:09 PM UTC-4, Ilan Mayer wrote:
On Saturday, June 18, 2022 at 12:33:44 PM UTC-4, Richard Heathfield wrote: >>>> On 18/06/2022 4:34 pm, leflynn wrote:Nice program. The solution found in 1750 was
[Program as spoiler space]On Friday, June 17, 2022 at 5:17:35 PM UTC-4, Mark Brader wrote:For all X, Y, and Z in the range 0-1000 and none equal to the
L. Flynn:X+Y, |X-Y|, X+Z, |X-Z|, Y+Z, |Y-Z| are all squares.
To find three such numbers, that the sum or difference of any two of >>>>>>> them shall be a square number.That's an ambiguous "or". Does it mean that any number which is the >>>>>> sum or difference of two of the three numbers shall be a square, or does >>>>>> it mean that it shall be true that either the sum or the difference >>>>>> is a square?
In other words, if X and Y are two of the numbers and X > Y, is it >>>>>> required that X+Y and X-Y are both squares, or only one of them?
--
other two, I found no solutions.
--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within
using System;
using System.Collections.Generic;
namespace SquaresPuzzle
{
class SquaresPuzzle
{
private const int N = 1000;
static void Main()
{
List<int[]> numbers = new List<int[]>();
for (int n1 = 1; n1 <= N; n1++)
{
for (int n2 = 1; n2 < n1; n2++)
{
if (n1 % 2 == n2 % 2)
{
int n1Squared = n1 * n1;
int n2Squared = n2 * n2;
int m1 = (n1Squared + n2Squared) / 2;
int m2 = (n1Squared - n2Squared) / 2;
numbers.Add(new[] { m1, m2 });
}
}
}
Comparer comparer = new Comparer();
numbers.Sort(comparer);
for (int n = 1; n < numbers.Count; n++)
{
if (numbers[n][0] == numbers[n - 1][0])
{
int n1 = numbers[n - 1][1];
int n2 = numbers[n][1];
int[] number1 = new[] { n1, n2 };
int[] number2 = new[] { n2, n1 };
if (numbers.BinarySearch(number1, comparer) >= 0 || numbers.BinarySearch(number2, comparer) >= 0)
{
Console.WriteLine("{0}, {1}, {2}", numbers[n][0], n1, n2);
}
}
}
}
public class Comparer : IComparer<int[]>
{
public int Compare(int[] x, int[] y)
{
int result = x[0].CompareTo(y[0]);
if (result == 0)
{
result = x[1].CompareTo(y[1]);
}
return result;
}
}
}
}
The program comes up with:
434657, 150568, 420968
Please reply to ilanlmayer at gmail dot com
__/\__
\ /
__/\\ //\__ Ilan Mayer
\ /
/__ __\ Toronto, Canada
/__ __\
||
Answered by Mr. C. Bumpkin . By a method of substitution , too tedious to insert , he finds 1873432 , 2399057 , 2288168 , the three numbers , answering the conditions of the question .
I did not realize that the name was an alias until prodded by Richard Tobin. >>
L. Flynn
Revised program:
using System;
using System.Collections.Generic;
namespace SquaresPuzzle
{
class SquaresPuzzle
{
private const int N = 3000;
static void Main()
{
List<int[]> numbers = new List<int[]>();
for (int n1 = 1; n1 <= N; n1++)
{
for (int n2 = 1; n2 < n1; n2++)
{
if (n1 % 2 == n2 % 2)
{
int n1Squared = n1 * n1;
int n2Squared = n2 * n2;
int m1 = (n1Squared + n2Squared) / 2;
int m2 = (n1Squared - n2Squared) / 2;
numbers.Add(new[] { m1, m2 });
}
}
}
Comparer comparer = new Comparer();
numbers.Sort(comparer);
for (int n = 0; n < numbers.Count; n++)
{
int m = n;
while (++m < numbers.Count && numbers[m][0] == numbers[n][0])
{
int n1 = numbers[n][1];
int n2 = numbers[m][1];
int[] number1 = new[] { n1, n2 };
int[] number2 = new[] { n2, n1 };
if (numbers.BinarySearch(number1, comparer) >= 0 || numbers.BinarySearch(number2, comparer) >= 0)
{
int n0 = numbers[n][0];
int divisor1 = FirstDivisor(n0);
int divisor2 = FirstDivisor(n1);
int divisor3 = FirstDivisor(n2);
if (divisor1 != divisor2 || divisor1 != divisor3)
{
Console.WriteLine("{0}, {1}, {2}", n0, n1, n2);
}
}
}
}
}
private static int FirstDivisor(int number)
{
if (number % 2 == 0)
{
return 2;
}
int root = (int) Math.Sqrt(number);
for (int n = 3; n <= root; n += 2)
{
if (number % n == 0)
{
return n;
}
}
return number;
}
public class Comparer : IComparer<int[]>
{
public int Compare(int[] x, int[] y)
{
int result = x[0].CompareTo(y[0]);
if (result == 0)
{
result = x[1].CompareTo(y[1]);
}
return result;
}
}
}
}
It produces 5 solutions (excluding solutions where all 3 numbers share a divisor), including the original one:
434657, 150568, 420968
733025, 418304, 488000
2399057, 1873432, 2288168
3911913, 1355112, 3788712
5320193, 589568, 1782032
Please reply to ilanlmayer at gmail dot com
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 322 |
Nodes: | 16 (0 / 16) |
Uptime: | 149:03:48 |
Calls: | 7,072 |
Calls today: | 1 |
Files: | 12,494 |
Messages: | 5,499,346 |