Problems & Puzzles: Puzzles

 Puzzle 986. Consecutive primes from a given set of integers. Gennady Gusev sent the following very nice puzzle:   Find a set of N numbers and expressions with them using the 4 basic arithmetic operations (+, -, *, /) and brackets, and always using the whole set of these numbers, just once each if them, that yield the longest consecutive primes starting in 2.   Gennady sent the following example:   The first 100 primes, from 2 to 541, from the following set of N=5 integers: (2, 8, 16, 19, 21).   2 = 2*8-16-19+21       3 = 2*8/16-19+21       5 = 2+8*(19-16)-21  7 = 2*(8-16+21)-19    11 = (2-8-16)/(19-21)  13 = (2-8*16)/21+19    17 = (2+8)/(16-21)+19  19 = (2*8-16)*21+19    23 = (2-8)/(16-19)+21   29 = 2*(21-8)-16+19    31 = 2*(8+16-19)+21    37 = 2*16+(19+21)/8    41 = 2*8/16+19+21      43 = 2*(8-16+19)+21    47 = 2-8*(16-19)+21    53 = 2*21+8-16+19      59 = 2*(8/16*21+19)    61 = 2*(8/16*19+21)    67 = 2*19-8+16+21      71 = 2*(8+16+21)-19    73 = 2+8-(16-19)*21    79 = 2*8-(16-19)*21    83 = 2*(16+19)-8+21    89 = 2-8-(16-21)*19    97 = 2/8*16*19+21     101 = 2*(16+21)+8+19   103 = 2/8*16*21+19     107 = 2+(8+16-19)*21   109 = 2*(8+16+21)+19   113 = (2-16+19)*21+8   127 = 2/(19-21)+8*16   131 = (2+19)*8-16-21   137 = 2-(8+19)*(16-21)  139 = 8+16/2*19-21     149 = 2+8*19+16-21     151 = 2-(8-16)*21-19   157 = 2-(8-19)*16-21   163 = 2*16+8*19-21     167 = 2+8*21+16-19     173 = 2+8*21-16+19     179 = 8*21-16/2+19     181 = 2*16+8*21-19     191 = (2-8+16)*21-19   193 = (2-21)*(8-19)-16 197 = 2*(8*16-19)-21   199 = 2-(8-19)*16+21   211 = (2-8+16)*19+21   223 = (19-8)*21-16/2   227 = (2+8)*19+16+21   229 = (2-8+16)*21+19   233 = 2+(8-16+19)*21   239 = 2*(8*16-19)+21   241 = (8-2)*(16+21)+19 251 = 2*(8*19-16)-21   257 = (2-8+19)*21-16   263 = 2*16-(8-19)*21   269 = (2-8+21)*19-16   271 = (8+16)/2*21+19   277 = 2-8+16*19-21     281 = (2*16-19)*21+8   283 = 2*8*(19-21/16)   293 = 2+8+16*19-21     307 = (2+19)*16-8-21   311 = 2-8+16*21-19     313 = (2+16)*19-8-21   317 = 2+8*(16+21)+19   331 = 2*16*(19-8)-21   337 = 19*(21-2)-8-16   347 = (8/2+19)*16-21   349 = 2-8+16*21+19     353 = 8-(2-21)*19-16   359 = (2/8+21)*16+19   367 = (2+16)*21+8-19   373 = 2*16*(19-8)+21   379 = (2+21)*16-8+19   383 = 2*(8-16)+19*21   389 = (2+8)*(16+21)+19 397 = 2*16*(21-8)-19   401 = (8/2+16)*19+21   409 = 2-8+16+19*21     419 = 8/2+16+19*21     421 = 8-2+16+19*21     431 = 2*8+16+19*21     433 = (2+19)*21+8-16   439 = 2*16+8+19*21     443 = (2+8+19)*16-21   449 = (2+19)*21-8+16   457 = 2-(8-21)*(16+19) 461 = (2+21)*19+8+16   463 = 8/2*16+19*21     467 = (8/2+19)*21-16   479 = 2+(8+16)*19+21   487 = 2+(8+16)*21-19   491 = (8/2+21)*19+16   499 = (8/2+19)*21+16   503 = (2+16)*(8+21)-19  509 = (8-2+19)*21-16   521 = (8+16)*21-2+19   523 = (2*16-8)*21+19   541 = (2+16)*(8+21)+19 Q1. Is it possible to get the first 100 primes from a "better" set of integers ("better" stands for less than five terms or  for five terms whose sum is smaller than 66). Q2. Send your best solution for the first 1000 primes.

Contribution came from Gennady Gusev the week 17-24 January, 2020

***

This is my solution of Q2: 1003 consecutive primes with the set of 7 numbers:  {...} .See attached file 1003.zip.

N.B. by CR: I will keep veiled the solution sent by Gennady, for the 1003 consecutive primes, for a while or after a first solution comes from another puzzler.

See note below on the Mark Mammel results

***

Paul Cleary wrote on Jan 31, 2020

Was unable to find any solutions with a sum of 65 or 64 and incidentally, there are no other solutions than the one published here with sum = 66 with {2, 8, 16, 19, 21}.

Here are a few stats I found, with sum = to 66 using {2, 8, 16, 19, 21} and only using {+, -, *, / and ()}.  There are 22352 ways to generate primes. number 2 can be generated the most ways with 2496 different ways and the least is 4 ways with both 347 and 467. The number of different primes generated are 144, the largest being 3139.

***

Mark Mammel wrote on Feb 01, 2020:

Attached is my solution for Q2, Puzzle 986 using the set of 7 numbers
set = {2, 5, 6, 7, 8, 9, 56}...
Wow, I found a much smaller solution with
{ 2,6,7,8,9,11,15} attached.
I found equally small sets with:
{4,5,6,7,8,9,19}
and
{5,6,7,8,9,10,13}

Here is his file for the set { 2,6,7,8,9,11,15} which sum up to 58.

BTW, the solution sent last week by Gennady Gusev used a set of 7 integers {12 13 15 17 18 19 20} but with a sum higher, 114. Here is file.

***

Gennady checked the solution for Q2 sent by Mark Mammel and found only one mistake:

`3089 <> 15 / 6 / 2 * 7 * 8 * 11 + 9 `
My correction : 3089 = 15 / 6 * 2 * 7 * 8 * 11 + 9

Other than that I accept that the Mark's solution is better than the mine

Mark replied:

Thanks to Gennady for catching this one -- it looks like I missed needed parenthesis in this case, my output should have been:

3089 = 15 / (6 / 2) * 7 * 8 * 11 + 9

My program was using only integer divisions. But of course Gennady's correction is equivalent. I will try to check my list to see if there are any other similar cases where parenthesis are needed. I tried to avoid unneeded parenthesis, but did not take into account that case.

***

 Records   |  Conjectures  |  Problems  |  Puzzles