Here's an interesting partitioning problem: Split the first N primes into 2 groups such that the difference of products is as small as possible but not 1. If this number is less than the square of the Nth prime, it will be prime. For example:
split 2,3,5 into 2 groups: (2,5) and (3) the difference of their products 2x5-3 = 7.
split 2,3,5,7 into 2 groups (3,7) and (2,5) the difference is 11. Note that (2,7) and (3,5) has a difference of 1 so don't go there.
5x11 - 2x3x7 = 13
Is it always possible to create a partition that produces the N+1th prime?
AFAIK this is a problem of my own conjuring, but I also know that most such things already exist and have a name.
It's an interesting heuristic, but I think your limitation that it be less than the square of the Nth prime is a case of overfitting.
Here's a list of results for the first N primes, for different Ns:
3: 7
4: 11
5: 13
6: 17
7: 107
8: 41
9: 157
10: 1811
11: 1579
12: 18859
13: 95533
14: 310469
15: 1995293
16: 208303
17: 2396687
18: 58513111
19: 299808329
20: 2933961157
21: 3952306763
22: 33298242781
23: 115405393057
I just wrote a script to brute force all combinations here, so the 24th iteration got very slow, but of all those the nonprime ones are n=23, 19, 18, 16, 14, and 13.
So, your rule appears to hold true as long as N is less than the cube of the Nth prime. The actual rule is probably more complex than a simple power, considering 83^5 is far less than the result in N=23.
I think I'll play with this a bit more this evening then ping some mathematician friends about it. They always love playing with weird properties of primes.
>> It's an interesting heuristic, but I think your limitation that it be less than the square of the Nth prime is a case of overfitting.
Maybe, but the result is obviously guaranteed to not be a multiple of any of the N primes. Since the smallest factor has to be greater than N, that means prime for up to N^2 (or (N+1)^2 I suppose).
I don't recall. I don't think I went beyond the use of 32bit integers (or was it 64) when I first looked at it, so not very large. The intermediate products can get quite big quickly. I do remember using a binary number to represent group membership of each prime, and seeing a pattern that broke down after only a few primes.
Just had a great idea for exploring this... If you add the logarithms of the primes in a group you can know how big the product will be. The products must be of similar size, and if so you can do the math mod k where k is a power of 2, like 2^64. This might allow some speedy C code without bignum support.
split 2,3,5 into 2 groups: (2,5) and (3) the difference of their products 2x5-3 = 7.
split 2,3,5,7 into 2 groups (3,7) and (2,5) the difference is 11. Note that (2,7) and (3,5) has a difference of 1 so don't go there.
5x11 - 2x3x7 = 13
Is it always possible to create a partition that produces the N+1th prime?
AFAIK this is a problem of my own conjuring, but I also know that most such things already exist and have a name.