**From New Scientist #2447, 15th May 2004** [link]

I have constructed a cyclical chain of 3-digit numbers, where each number starts with the digit (which is never 0) that was the last digit of the previous number in the chain, and the numbers in the chain are alternately perfect squares and triangular numbers.

The chain consist of as many numbers as is possible, consistent with the requirements outlined above and the stipulation that no number may appear in it more than once.

How many numbers are there in the chain?

**Note:** I am still waiting for a phone line to be connected at my new house, so I only have sporadic access to the internet at the moment.

[enigma1289]

### Like this:

Like Loading...

*Related*

This Python code runs in 239ms.

Solution:There are 14 numbers in a maximal length chain.Here’s an example chain of length 14: (121, 105, 529, 903, 324, 406, 676, 666, 625, 528, 841, 153, 361, 171).

Because the chain must form a closed loop of alternating squares and triangular numbers the solution can only be a chain with even length.

But we can find longer sequences with alternating squares and triangular numbers that are of odd length, but when formed into a closed loop two numbers of the same type will be next to each other.

Here’s an example chain of length 17: (561, 144, 496, 676, 666, 625, 528, 841, 171, 121, 153, 361, 105, 529, 903, 324, 465).

When formed into a loop 561 = T(33) and 465 = T(30) will be adjacent.

I wish to challenge the meaning of “cyclical chain”. To me it means following a predetermined cycle (i.e. alternate squares and triangular numbers), not that it has to be “circular”. Anyway, I got a chain 19 numbers long, beginning and ending with triangular numbers – 225 – 528 – 841 – 171 – 121 – 105 – 529 – 946 – 676 – 666 – 625 – 561 – 169 – 903 – 361 – 153 – 324 – 465 – 576. Happy days! (8 October 2014)

The published solution was that there were 14 numbers in the chain, so I think the setter was intending the numbers to be formed into a circle. They probably could have been a bit more explicit in the problem statement.

If you relax the conditions so you’re just looking for an alternating sequence (that doesn’t have to form a closed loop) then 19 is indeed the maximal length you can achieve.