Sunday Times Teaser 3154 – Gill’s Primes
by Bill Kinally
Published Sunday March 05 2023 (link)
Jack told Gill “I have found three equallyspaced 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 equallyspaced 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 threedigit 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 →

Brian Gladman permalink123456789101112131415161718from itertools import combinationsfrom number_theory import Primes# three digit primes with odd digit sums and no repeated digitsprms = tuple(p for p in Primes().range(100, 1000)if len(set(str(p))) == 3 and sum(int(x) for x in str(p)) & 1)# consider two such primes ...for a, b in combinations(prms, 2):# ... with six different digitssab = set(str(a) + str(b))if len(sab) == 6:# add a third such prime that forms an equally spaced# sequence with nine different digits in totalif (c := 2 * b  a) in prms and not sab.intersection(str(c)):print(f"Gill's primes are: {a}, {b} and {c}.")

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 equallyspaced primesif DEF  ABC == GHI  DEF :print(f"Gill's primes are {ABC}, {DEF} and {GHI}.")

GeoffR permalink123456789101112131415161718from number_theory import is_primefrom itertools import combinationsPR = [n for n in range(101, 1000, 2) if is_prime(n)]for a, b in combinations(PR, 2):if len(set(str(a) + str(b))) == 6:# Digit sums of three threedigit primes are oddif (sum(int(x) for x in str(a)) % 2 == 1 andsum(int(x) for x in str(b)) % 2 == 1):# 3rd prime is average of previous two primes#.. in order to get equally spaced primesc = (a + b) // 2if is_prime(c) and sum(int(x) for x in str(c)) % 2 == 1:if len(set(str(a) + str(b) + str(c))) == 9:print(f"Gill's three primes are {a}, {c} and {b}.")

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}.")