Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

If food be the music of love, eat up, eat up.


interests / rec.puzzles / Re: Mathematical Recreation Problem from 1749

Re: Mathematical Recreation Problem from 1749

<t8ppd3$ci4$1@dont-email.me>

  copy mid

https://www.novabbs.com/interests/article-flat.php?id=197&group=rec.puzzles#197

  copy link   Newsgroups: rec.puzzles
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Pancho.J...@proton.me (Pancho)
Newsgroups: rec.puzzles
Subject: Re: Mathematical Recreation Problem from 1749
Date: Mon, 20 Jun 2022 13:32:35 +0100
Organization: A noiseless patient Spider
Lines: 276
Message-ID: <t8ppd3$ci4$1@dont-email.me>
References: <0361098f-6745-426a-bf20-e86a100afaa2n@googlegroups.com>
<SbCdnRtjqpH6cjH_nZ2dnUU7-eHNnZ2d@giganews.com>
<a0f4227c-bb78-49cd-ae56-bdf3eb09d07fn@googlegroups.com>
<t8kup5$rbi$1@dont-email.me>
<bd1ead95-c36d-47e1-8553-8e3aa1c3813en@googlegroups.com>
<c8c45b51-74c3-45b2-9e66-161c95edd5f3n@googlegroups.com>
<e2837d97-828c-4bd3-a48d-2da8abe9fd5cn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 20 Jun 2022 12:32:35 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="56931baad2d856b82e6d1e059793e2cd";
logging-data="12868"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+zVxOehGyGnyhiP1txgUH+lFk320wOCgE="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.3.0
Cancel-Lock: sha1:AnaTOdyBxuW3IzBbaCTYG0eXNZs=
In-Reply-To: <e2837d97-828c-4bd3-a48d-2da8abe9fd5cn@googlegroups.com>
Content-Language: en-GB
 by: Pancho - Mon, 20 Jun 2022 12:32 UTC

On 19/06/2022 15:33, Ilan Mayer wrote:
> 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:
>>>>>> 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?
>>>>>> --
>>>>> X+Y, |X-Y|, X+Z, |X-Z|, Y+Z, |Y-Z| are all squares.
>>>> For all X, Y, and Z in the range 0-1000 and none equal to the
>>>> 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
>>> [Program as spoiler space]
>>>
>>> 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.
>>
>> 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
>

Here is a few more

Solution 88642, 891458, 3713858
Solution 150568, 420968, 434657
Solution 418304, 488000, 733025
Solution 589568, 1782032, 5320193
Solution 602272, 1683872, 1738628
Solution 856350, 949986, 993250
Solution 1355112, 3788712, 3911913
Solution 1673216, 1952000, 2932100
Solution 1761858, 2040642, 2843458
Solution 1873432, 2288168, 2399057
Solution 3425400, 3799944, 3973000

=====
Slightly different program, Square check i+j,j+k are redundant, but I
couldn't be bothered to remove them from the first version that was too
slow.

Java...

package com.company;

public class Main {

public static void main(String[] args) {
doCheck( 10000000);
}

public static void doCheck(long maxtest){
long sqrtMaxtext = (long)Math.floor(Math.sqrt(maxtest)) +1;
for (long i = 1; i < maxtest; i++) {
long sqrt2i = (long)Math.floor(Math.sqrt(2*i))+1;
for (long sj = sqrt2i; sj < sqrtMaxtext; sj++) {
long j = sj*sj-i;
if (isSquare(i + j) && isSquare(j - i)) {
long sqrt2j = (long)Math.floor(Math.sqrt(2*j))+1;
for (long sk = sqrt2j; sk < sqrtMaxtext; sk++) {
long k= sk*sk-j;
if (isSquare(k + i)
&& isSquare(k - i)
&& isSquare(k + j)
&& isSquare(k - j)
) {

System.out.printf("Solution %d, %d, %d\n",
i, j, k);
}
}
}
}
}
}

public static boolean isSquare(long x){
long root = (long)Math.floor(Math.sqrt(x));
return ((root * root - x) == 0);
}

}

SubjectRepliesAuthor
o Mathematical Recreation Problem from 1749

By: leflynn on Fri, 17 Jun 2022

19leflynn
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor