Teaser 2970: Puzzling powers
From The Sunday Times, 25th August 2019 [link] [link]
I came across a most remarkable number recently and wrote it down. All its digits were different and it was divisible by 11. In itself, that wasn’t particularly interesting, but I wrote down the number of digits in the number and then wrote down the sum of the digits in the number.
I therefore had three numbers written down. What surprised me was that of the three numbers, one was a square and two were cubes.
What is the remarkable number?
[teaser2970]
Jim Randell 7:42 am on 24 August 2019 Permalink |
I started without making the assumption that the numbers are separately a square, a cube and a cube (in some order), i.e. one of them could be both a square and a cube.
The smallest numbers that are both squares and cubes are 0, 1, 64, 729, … (i.e. the powers of 6).
So we can write down 0 (a multiple of 11 using all different digits), which has 1 digit and a digit sum of 0. And we can say one of them is a square and two of them are cubes (as they are all both squares and cubes). If however, we require exactly 1 of them to be a square and exactly 2 of them to be cubes we can eliminate this solution.
The number of digits is going to be between 1 and 10, and the digits sum is going to be between 0 and 45, so neither of those can be both a square and a cube, which means that the multiple of 11 must be either a square or a cube (possibly both), so can be written as either (11.m)² or (11.m)³.
This Python program considers numbers of this form, and finds only one solution. It runs in 157ms.
Run: [ @repl.it ]
from enigma import (irange, iroot, nsplit, icount_exactly as count, is_square, is_cube, printf) # consider multiples of 11 both squared and cubed for p in (2, 3): for m in irange(11, iroot(9876543210, p), step=11): n = m**p # digits ds = nsplit(n) # number of digits k = len(ds) # all digits different if len(set(ds)) != k: continue # digit sum s = sum(ds) # one is a square, two are cubes ns = (n, k, s) if count(ns, is_square, 1) and count(ns, is_cube, 2): printf("n={n} k={k} s={s}")Solution: The number is 26198073.
Changing [[
count()]] to use [[icount_at_least()]] does not yield any further solutions.The number is (27×11)³.
The digit length is 8 (= 2³).
The digit sum is 36 (= 6²).
If we look at the 6th power of multiples of 11 we find that the powers of 11, 22, 33, 44 all have repeated digits, and the power of 55 is longer than 10 digits. So none of the numbers are going to be both a square and a cube. We can use this analysis to reduce the run time of the program, for example we only have to check numbers with 1, 4, 8, 9 digits. So we can reduce the maximum possible number (at line 5) to 987654321.
For k = 1 the only possible value is n = 0, and we have already eliminated this as a solution.
For k = 4 (a square), the only multiple of 11 cubed with 4 digits is n = 11³ = 1331, which has repeated digits.
For k = 8 (a cube) and k = 9 (a square) the only possible digit sum is s = 36 (a square), so we see the solution must be a multiple of 11 cubed, with 8 different digits and a digit sum of 36. So we only have to check values n = (11.m)³ for m = 20 … 42 to find a value with 8 different digits. There are 2 possible values, and only one of these has a digit sum of 36.
LikeLike