Sunday Times Teaser 3154 – Gill’s Primes
by Bill Kinally
Published Sunday March 05 2023 (link)
Jack told Gill “I have found three equally-spaced prime numbers 29, 41, and 53. The difference between the first and second is the same as the difference between the second and third, and there are no repeated digits in the six digits of my primes”. Gill told Jack she had also found three equally-spaced primes, each having three digits and with no repeated digits in the nine digits of her primes. She said, “If I told you that the three-digit sum of each of my primes is an odd number then you should be able to find them”.
In ascending order what are Gill’s three primes?
5 Comments
Leave one →
-
GeoffR permalink1234567891011121314151617181920212223242526272829303132333435363738from itertools import permutationsfrom number_theory import is_prime# 1st stage permutation - prime ABCfor p1 in permutations ('1234567890', 3):A, B, C = p1if '0' in (A, C) :continueABC = int(A + B + C)if not is_prime(ABC) or (int(A) + int(B) + int(C)) % 2 == 0:continue# 2nd stage permutation - prime DEFqs = set('1234567890'). difference(p1)for p2 in permutations(qs, 3):D, E, F = p2if '0' in (D, F):continueDEF = int(D + E + F)if not is_prime(DEF) or (int(D) + int(E) + int(F)) % 2 == 0:continue# 3rd stage permutation - prime GHIqs2 = qs.difference(p2)for p3 in permutations(qs2, 3):G, H, I = p3if '0' in (G, I):continueGHI = int(G + H + I)if not is_prime(GHI) or (int(G) + int(H) + int(I)) % 2 == 0:continue# Put primes in ascending orderif int(A) < int(D) < int(G):# Check for three equally-spaced primesif DEF - ABC == GHI - DEF :print(f"Gill's primes are {ABC}, {DEF} and {GHI}.")
-
GeoffR permalink123456789101112131415161718from number_theory import is_primefrom itertools import combinationsdef chk_sum(n):if sum(int(x) for x in str(n)) % 2 == 1:return Truereturn FalsePR = [n for n in range(101, 1000, 2) if is_prime(n)and len(set(str(n))) == 3]for a, b, c in combinations(PR, 3):if len(set(str(a) + str(b) + str(c))) == 9:if b - a == c - b:if all(chk_sum(x) for x in (a, b, c)):print(f"Gill's primes are {a}, {b} and {c}.")
-
GeoffR permalink12345678910111213141516171819from number_theory import is_primefrom itertools import combinationsdef sum_odd(n):return (sum(int(x) for x in str(n)) % 2 == 1)PR = [n for n in range(101, 1000, 2) if is_prime(n)and len(set(str(n))) == 3]for A in PR:if sum_odd(A):for B in PR:if B > A and sum_odd(B) and len(set(str(A) + str(B))) == 6:C = 2 * B - Aif C in PR and sum_odd(C):if len(set(str(A) + (str(B) + str(C)))) == 9:print(f"Gill's three primes are {A}, {B} and {C}.")