Sunday Times Teaser 2536 – ELEMENTARY
by Danny Roth and Victor Bryant
Published: 1 May 2011 (link)
“Every number has some significance,” said Holmes, referring to his monograph on the subject. “Then what do you make of this?” asked Watson, scribbling a seven-digit number on the desk diary. “Apart from the obvious fact that it is your old Indian army number,” replied Holmes, “I see that it is the largest seven-digit number where the difference between it and its reverse is the cube of a factor of the number itself.”
What was Watson’s number?
One Comment
Leave one →
-
Brian Gladman permalink1234567891011121314# seven digit numbers staring with the largestfor nbr in range(10000000, 1000000, -1):# the difference between the number and that# with its digits reverseddif = abs(nbr - int(str(nbr)[::-1]))if dif:# find whether the cube root of the difference# is an integer that is a factor of the numbercr = int(dif ** (1/3) + 0.5)if dif == cr ** 3 and not nbr % cr:print("Watson's nummber is {}.".format(nbr))break