Sunday Times Teaser 3306 – Pin-up
by Victor Bryant
Published Sunday February 01 2026 (link)
Over the years I have used seven different PINs. The first consisted of a four-digit number (the first digit not being zero), and thereafter each new PIN was obtained by swapping over two of the digits of the previous PIN; each time this increased the PIN.
The first PIN (not surprisingly!) was divisible by 1, the second was divisible by 2, the third by 3, and so on, with the seventh divisible by 7 (in fact the seventh PIN was the only one divisible by 7).
What was the third PIN?
3 Comments
Leave one →
Brilliant solution, Brian! I’m a bit uncomfortable with changing the value of a parameter within a recursive function, though. I would have preferred something like this:
Hi John,
I am guessing its my line 5 you feel uncomfortable with. I understand it
looks a bit out of place but my reason for this is that I prefer my ps
variable to be a pure output only variable and my p to be the input variable.
I can load ps from p in the call to pins but that seems a bit awkward so I
decided to do it as a part of the recursion. From the respective of the
recursion on line 19 it just means that the update to ps is delayed to
the start of the next recursion.
But its always good to develop and maintain a personal style!