# Sunday Times Teaser 2990 – Squares and Cubes

*by Howard Williams*

#### Published January 12 2020 (link)

Jenny is pleased that she has found two whole numbers with a remarkable property. One of them is a single digit greater than zero while the other one has two digits. The remarkable thing is that the difference of their squares is a perfect cube and the difference of their cubes is a perfect square.

Her sister Sarah is not impressed, however. She has found two three-digit numbers for which the difference of their squares is also a perfect cube and the difference of their cubes is also a perfect square.

In ascending order, what are the four numbers?

4 Comments
Leave one →

Here is a faster way of finding larger solutions:

By adapting my code, I found the four digits numbers,

(mentioned in Brian’s manual site), as follows:

(4374 and 7290) and (5687 and 8954).

Further code modification found five digit numbers:

(17576 and 52728), (24576 and 40960),

(27783 and 55566), (64350 and 70434).

These numbers slowed my laptop considerably.

Then I came across Brian’s extra programme for finding larger solutions.

It analyses the constraints for finding squares and cube differences

in the same way as the original teaser.

It proved very fast and efficient in finding all integer

solutions up to 1,000,000.

So I made the programme work a bit harder, finding all the integer

solutions up to 10,000,000. It was still reasonably fast.

I had to extend the search path up to 100,000,000 to make the

programme visibly slow down,although it still worked OK!

The three top numbers found with an upper search limit

of 100,000,000 were as follows:

# x=13,880,646, y=76,343,553 (s=665,042,570,829, c=177,957)

# x=23,625,784, y=81,934,280 (s=732,704,560,736, c=183,264)

# x=27,068,670, y=94,740,345 (s=911,334,447,225, c=202,005)

As well as a very efficient programme, I consider this output

is also a testament to Python’s numerical abilities.