Straight Dope Message Board (https://boards.straightdope.com/sdmb/index.php)
-   The Game Room (https://boards.straightdope.com/sdmb/forumdisplay.php?f=17)
-   -   Games Magazine Wild Cards numbers game (https://boards.straightdope.com/sdmb/showthread.php?t=885502)

 Knowed Out 11-17-2019 01:05 PM

Games Magazine Wild Cards numbers game

The January 2020 edition of Games magazine had a Wild Cards puzzle that I couldn't solve, and the solution they gave doesn't provide the steps taken to arrive at the answer. There has to be a better way than trial and error.

Quote:
 Can you find two three-digit whole numbers a and b such that both the following statements are true? The difference between a and b is a three-digit perfect square. The difference between the squares of a and b is either 1 less or 1 more than the product of a and b. Hint: One of the numbers is prime.
The second statement can be expressed as:

a2 - b2 = ab ± 1
(a + b)(a - b) = ab ± 1
(a - b) = (ab ± 1) / (a + b)

a - b is a three-digit perfect square, listed here: 102 to 312

I ruled out the top three, since the difference between two three digit numbers can't be more than 800. So, we're left with 102 to 282, 19 possibilities for a - b.

If a or b is prime, that leaves 145 possibilities for either, listed here.

At this point, I couldn't figure out any way to simplify or narrow down the possibilities. Going forward, I could only see using trial and error, and there's way too many permutations to slog through.

And so Doper geniuses, I turn to you. What's the proper way to determine the solution? Here it is in spoiler tags, in case this stumps you too.

SPOILER:
236 and 377
Difference: 377 - 233 = 144 = 12 x 12
Difference of squares: 377 x 377 - 233 x 233 = 87840
Product: 377 x 233 = 87841
233 is prime
377 = 13 x 29

Note: The number pairs for which the second statement in the puzzle is true are successive numbers in the Fibonacci series.

 markn+ 11-17-2019 01:20 PM

Probably not what you want, but I just wrote a quick 15-line Perl script to search all 900*900 possibilities. Took me about 2 minutes.

Nitpick: there's a typo in one of the numbers in the first line of your spoiler.

 Chronos 11-17-2019 05:39 PM

OK, start from the first equation, a^2 - b^2 = ab ± 1. Since a and b are both three-digit numbers, ab is going to be five to seven digits, meaning that that ±1 is almost irrelevant. So to a very good approximation, a^2 - ab + b^2 = 0. Defining x == a/b, this means that x^2 - x - 1 ~= 0, or x ~= (1+sqrt(5))/2 ~= 1.61803 (incidentally, the Golden Ratio, phi). In other words, a ~= 1.61803 * b, or a-b ~= 0.61803*b is a perfect square, or b is a three-digit perfect square times 1.61803 . That only leaves us nine numbers to check, 100 to 324 (any higher square would leave a and/or b with four digits).

Just computing the b values corresponding to those perfect squares, I notice very quickly that phi*144 is very, very close to an integer. So let's start there. phi*144 = 232.99632, so call it 233. And 233*phi = 377.001919, also really close to an integer. So it looks really likely that our numbers will be 233 and 377.

377^2 - 233^2 = 142129 - 54289 = 87840, and 233*377 = 87841. Looks like we've got it.

 Colibri 11-17-2019 05:57 PM

Moved to the Game Room.

Colibri
General Questions Moderator

 Knowed Out 11-17-2019 07:19 PM

Quote:
 Originally Posted by Chronos (Post 21978663) OK, start from the first equation, a^2 - b^2 = ab ± 1. Since a and b are both three-digit numbers, ab is going to be five to seven digits, meaning that that ±1 is almost irrelevant. So to a very good approximation, a^2 - ab + b^2 = 0. Defining x == a/b, this means that x^2 - x - 1 ~= 0, or x ~= (1+sqrt(5))/2 ~= 1.61803
The first equation is a2 - b2 = ab ± 1, but when you shifted ab over, shouldn't the result be a2 - ab - b2 ~= 0?

Also, if you're defining x == a/b, wouldn't the the result be b2x2 - ab - a2/x2 ~= 0? How did you get x2 - x -1 ~= 0? Moreover, how did you leap to x ~= (1+sqrt(5))/2?

 Knowed Out 11-17-2019 07:21 PM

Quote:
 Originally Posted by markn+ (Post 21978246) Probably not what you want, but I just wrote a quick 15-line Perl script to search all 900*900 possibilities. Took me about 2 minutes. Nitpick: there's a typo in one of the numbers in the first line of your spoiler.
Good job, but I doubt knowledge of Perl was a requirement. :-)

The first line of the spoiler should be 233, not 236. Thanks for spotting that.

 Chronos 11-17-2019 08:16 PM

The first was a typo in the post, that was not reflected in my actual calculations: It should say a^2 - ab - b^2 = 0. The same typo did not show up in the x equation.

The second came from replacing every instance of a with x*b (and leaving the instances of b alone), and then factoring out all of the b^2 pieces.

And the third was the Quadratic Formula. There are actually two solutions, but the other solution corresponded to calling a the smaller number and b the larger number, which is really no different.

 Left Hand of Dorkness 11-17-2019 10:57 PM

I dunno if this is helpful, but you can rule out any pair in which both numbers are even. The squares of an even number will always be even, the product of two even numbers will always be even, and the difference between the squares of two even numbers will always be even. So you can't have a2 - b2 = ab ± 1, since that would lead to one result or the other being odd.

If one number's odd and the other is even, their product will be even, and the difference between the squares will be odd, so that can work. And if both are odd, then the product will be odd, and the difference between the squares will be even, so that can work. But no pairs of even numbers would work.

Edit: The hint tells you one of the numbers is prime, which means all that work is superfluous: that means one of the three-digit numbers must be odd. D'oh!

 Manlob 11-17-2019 11:21 PM

The solution given in the OP does explain where it came from: it says the 2nd relation applies to consecutive Fibonacci numbers (this follows from the Cassini identity). The difference of these is the Fibonacci number that comes before them, and it is required to be a square. The only square Fibonacci numbers are 0, 1, and 144. Only 144 is 3 digits, and b and a must be the next two Fibonacci numbers: 233 and 377.

Chronos' approach is headed in the direction of Fibonacci numbers too, since ratio of the two values is very close to the golden ratio.

 RickJay 11-18-2019 09:09 AM

Quote:
 Originally Posted by Knowed Out (Post 21978220) I ruled out the top three, since the difference between two three digit numbers can't be more than 800.
Wait, what? 999-100=899.

 Manlob 11-18-2019 10:42 PM

Another way to solve this without knowing the Cassini Identity: Let c2=a-b. Eliminate a from the two equations and solve for b, giving
b=(c2±sqrt(5c4±4)/2
For b to be integer, 5c4±4 must be a perfect square. Values of c meeting this can be found using the solution to Pell's equation, but it easier to just make a spreadsheet. Put "10" (representing c) in Column 1, sqrt(5c4-4) in Column 2, and sqrt(5c4+4) in Column 3. Drag the three cells down until Column 1 contains 31 (to cover all cases with c having 3 digits). It is immediately clear which value in Column 2 or 3 is the only integer: c=12, and the radical is 322.

Plug into the expression for b and add c2=144 to get a. The ± results in two solutions:
a=55 and b=-89 (which is rejected because they are not 3 digits)
a=377 and b=233.

 All times are GMT -5. The time now is 01:51 PM.