Let , and be three different two-digit primes, where the average of any two is a prime, and the average of all three is a prime.
Find
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
primerange is a generator that, in this case, supplies all of the two-digiti primes. combinations is another generator that, in this case, supplies all of the three-combinations of these primes. The code simply sifts through the combinations to identify any that satisfy the required conditions.
Since the average of any number of two-digit numbers will also be a two-digit number, apart from the decimals, I could have checked whether the averages are primes using table lookup. However, this approach, using isprime seemed more straightforward.
I split the if statement up into pieces in the misapprehension that this would be faster. Of course, if I had put all of the conditions together the interpreter would have stopped executing them as soon as one of them failed.