Sunday Times Teaser 2973 – Something in Common
by Victor Bryant
Published September 15 2019 (link)
I have written down four different numbers. The third number is the highest common factor of the first two (ie it is the largest number that divides exactly into both of them). The fourth number is the lowest common multiple of the first two (ie it is the smallest number that both of them divide exactly into).
I can consistently replace digits by letters in my numbers so that the highest common factor is HCF and the lowest common multiple is LCM.
What are the first two numbers?
2 Comments
Leave one →

GeoffR permalink12345678910111213141516171819202122232425from math import gcd as HCF# consider the two three digit numbersfor n1 in range(100, 1000):for n2 in range(n1 + 1, 1000):# find their highest common factor and lowest common multiplehcf = HCF(n1, n2)lcm = n1 * n2 // hcf# make sure that we have four different three digit numbersif hcf < 100 or lcm >= 1000 or len({hcf, n1, n2, lcm}) != 4:continue# Find HCF and LCM digitsh, c1, f = hcf // 100, hcf // 10 % 10, hcf % 10l, c2, m = lcm // 100, lcm // 10 % 10, lcm % 10# check middle digits of HCF and LCM are the same# and that that h, c, f, l, m are all differentif c1 != c2 or len({h, c1, f, l, m}) != 5:continueprint(f"1st number = {n1}, 2nd number = {n2}")print(f"HCF = {hcf}, LCM = {lcm}")