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 →
-
Brian Gladman permalink12345678910111213141516171819202122232425# return the digits of a three digit numberdef digits(x):ab, c = divmod(x, 10)return divmod(ab, 10) + (c,)# Since the two numbers must be co-prime multiples (m, n)# of the highest common factor, the four numbers are:## hcf, a = m.hcf, b = n.hcf, lcm = m.n.hcf## Since m and n are co-prime with a product less than 10,# the only possible values are m = 2, n = 3, which means# that the maximum value of hcf is 166for hcf in range(100, 167):a, b, lcm = 2 * hcf, 3 * hcf, 6 * hcf# find the digits in the highest common factor# and the lowest common multipled_hcf, d_lcm = digits(hcf), digits(lcm)# check that they have only one shared digit which is# also the tens digit in eachif len(set(d_hcf + d_lcm)) == 5 and d_hcf[1] == d_lcm[1]:print(f"{a}, {b} (hcf = {hcf}, lcm = {lcm})")
-
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}")