Sunday Times Teaser 2918 – Prime Multiplication
by Angela Newing
Published August 26 2018 (link)
Almost everyone knows that the single digit prime numbers are 2, 3, 5, and 7, the number 1 having been excluded quite a long time ago. Here is a multiplication involving prime digits
p | p | p | ||||
× | p | p | ||||
– | – | – | ||||
p | p | p | p | |||
p | p | p | p | |||
– | – | – | – | – | ||
p | p | p | p | p | ||
———— | — | — | — | — | — | — |
What is the answer?
One Comment
Leave one →
-
Brian Gladman permalink123456789101112from itertools import productcheck = lambda n: all(d in '2357' for d in str(n))for a, b, c, d, e in product((2, 3, 5, 7), repeat=5):abc = 100 * a + 10 * b + cde = 10 * d + eif check(abc * de) and check(abc * d) and check(abc * e):print(f' {abc}\n x {de}\n ----\n {e * abc}\n'f' {d * abc}\n -----\n {abc * de}\n -----')