Twin Prime Sandwich

An egregious number is an integer that is both one more than and one less than a prime number. For instance, 4 and 12 are egregious numbers. What is the highest common factor of all egregious numbers greater than 4?


The answer is 6.

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.

2 solutions

Bob Bob
Feb 27, 2015

Each egregious number is surrounded by two primes by definition

Therefore, we can denote said number by n, and we have a consecutive sequence of integers

n - 1, n, n + 1

where n -1 and n + 1 are prime

Note that neither n - 1 nor n + 1 can equal 2, as n - 1 = 2 implies n + 1 = 4, which is not prime, and n + 1 = 2 implies that n - 1 = 0, which is not prime

Also, n - 1 = 3 can be discounted as we stated n does not equal 4

And n + 1 = 3 can be discounted as it implies n - 1 = 1, which is not prime.

Therefore, neither n - 1 nor n + 1 can be divisible by 2 or 3, since a prime number is divisible by only 1 and itself and neither prime can equal 2 or 3

Considering three general consecutive integers, however, we note that one or two of them have to be divisible by two and exactly one of them has to be divisible by three

In this case, as neither prime number is divisible by either, clearly n is divisible by 2 and 3; thus we deduce that egregious numbers are all, except 4, divisible by 6

Noting that 6 is the first example of such a number greater than 4, the GCD/HCF must be 6

Bill Bell
Feb 26, 2015

The sympy library includes sieve, which is an array-like structure made to appear to contain as many prime numbers as are referenced in code.

In this case, an egregious number (erroneously called a 'possible') is identified by its position between two primes in sieve. As stated in the problem, we ignore the egregious number 4. We initialise gcd so far to 6 for the next egregious number, 6. Then we update the gcd for each new egregious number until we achieve convergence, convergence being no change in the updated gcd.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...