Henry has already argued that if p and q are consecutive primes then (p+q)%2 can not be prime. I just want to say that reasoning of the sort:
While it might be possible for the larger primes, I'm thinking not - just by induction. is unreliable, at best. That is, it is unreliable to come a conclusion by trying a few cases, or a few billion cases, and think that a property is true in general. http://en.wikipedia.org/wiki/Prime_number_theorem tells of one such instance: This suggests that Li(*x*) should usually be larger than π(*x*) by roughly Li(*x*1/2)/2, and in particular should usually be larger than π(*x*). However, in 1914, J. E. Littlewood proved that this is not always the case. The first value of *x* where π(*x*) exceeds Li(*x*) is probably around *x* = 10316; see the article on Skewes' number for more details. On Sun, May 12, 2013 at 3:07 AM, Alan Stebbens <[email protected]> wrote: > ProgrammingPraxis (at http://programmingpraxis.com/2013/05/10/mindcipher) > offered a problem asking, given p, q as two consecutive pairs of primes, if > (p+2)%2 could be prime. > > Since both p & q (> 2) are prime, their sum is an even number and not > prime, but could the half of their sum be a prime? > > I'm not much of a mathematician, but I figured I could brute-force an > approximation with J. > > The gist below is my experiment showing that the answer is no, for the > consecutive pairs of primes in the set of the first million primes. While > it might be possible for the larger primes, I'm thinking not - just by > induction. > > Probably some of you could show a proof, but it was more fun for me to > cobble up this in J, and also demonstrate J to the non-J audience at > Programming Praxis (which has been mostly scheme, Haskell, python, ruby). > > https://gist.github.com/aks/5563008 > > Here's my experiment: > > i. 20 > 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 > > NB. generate the first 20 primes > p: i. 20 > 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 > > NB. box up consecutive pairs of those primes > (2 <\ ]) p: i. 20 > > ┌───┬───┬───┬────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┬─────┐ > │2 3│3 5│5 7│7 11│11 13│13 17│17 19│19 23│23 29│29 31│31 37│37 41│41 43│43 > 47│47 53│53 59│59 61│61 67│67 71│ > > └───┴───┴───┴────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┴─────┘ > > NB. sum up each pair of primes > +/ each (2 <\ ])p: i. 20 > ┌─┬─┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬───┬───┬───┬───┬───┐ > │5│8│12│18│24│30│36│42│52│60│68│78│84│90│100│112│120│128│138│ > └─┴─┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴───┴───┴───┴───┴───┘ > > NB. divide each sum by 2 > 2 %~ each +/ each (2 <\ ])p: i. > 20 > > ┌───┬─┬─┬─┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐ > │2.5│4│6│9│12│15│18│21│26│30│34│39│42│45│50│56│60│64│69│ > └───┴─┴─┴─┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘ > > NB. now, test each of those results for being prime. 1 p: y -- tests y > for being prime > > 1&p: each 2 %~ each +/ each (2 <\ ])p: i. > 20 > > ┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐ > │0│0│0│0│0│0│0│0│0│0│0│0│0│0│0│0│0│0│0│ > └─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ > > NB. open the boxed results, so we can add them up > >1&p: each 2 %~ each +/ each (2 <\ ])p: i. 20 > 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 > > NB. sum/reduce the vector of booleans. If there's a prime, the sum will > be > 0 > +/>1&p: each 2 %~ each +/ each (2 <\ ])p: i. 20 > 0 > > NB. ok. No primes. Let's keep checking for larger groups > > +/>1&p: each 2 %~ each +/ each (2 <\ ])p: i. 1000 > 0 > +/>1&p: each 2 %~ each +/ each (2 <\ ])p: i. 10000 > 0 > +/>1&p: each 2 %~ each +/ each (2 <\ ])p: i. 100000 > 0 > > NB. the previous output took a few seconds. The next will take a few > minutes > > +/>1&p: each 2 %~ each +/ each (2 <\ ])p: i. 1000000 > 0 > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
