New Scientist Enigma 631 – Fidget Digit
by Susan Denham
From Issue #1785, 7th September 1991 (link)
My niece (whose age is a two-figure number) is very good at arithmetic, and to keep her occupied on a recent train journey I asked her to find a number with all its digits different and with the sum of its digits a multiple (more than one times) of her age.
She wrote down a list of lots of number with both those properties. So I then asked her to add 1 to each of her numbers, and to pick out from the new list each number which still had all its digits different and with the sum of its digits equal to a multiple (again, more than one times) of her age next birthday.
There were still quite a few numbers in this new list which had these properties. So I asked her to find one of them which, when multiplied by her age, gave an answer which still had all its digits different — which she did!
How old is she?
@Brian, if l is equal to 9 and age ends on a zero you can discard these entries (otherwise age times second list number will end on 2 zeros).
@Frits
Thanks for the thought. I would add this as a special case if the speed was
a problem but it isn’t. I don’t generally add special cases unless they are
needed because a program is unduly slow without them. Adding them often
makes it necessary to add a long comment to explain them and this makes the
program itself longer. Of course a single special case is not a big problem
but it is easy when speed is made a priority to end up adding multiple
special cases which have a negative impact on the overall clarity of the code.