# Increasing Goldbach partitions

The Goldbach conjecture states that:

every even number that is greater than 2 is the sum of two primes.

We will consider a Goldbach partition of a number n to be a pair of two primes adding to n. We are concerned with numbers is of increasing Goldbach partition. We measure the size of a number's Goldbach partitions by the size of the smallest prime in all of that number's partitions. A number is of increasing partition if this size is greater than the size of all smaller even numbers.

Given an even integer n > 2, determine if n is of increasing Goldbach partition, and output two unique values, one if it is and one if it is not.

This is , so you should aim to minimize the number of bytes in your source code.

OEIS A025018

• – Post Rock Garf Hunter Jul 3 '17 at 14:31
• It is good question, that is difficult to understand. I edited it to simplify the wording. Please check it, and if all is correct apply changes. – Евгений Новиков Jul 3 '17 at 16:38
• @ЕвгенийНовиков I found your edit more confusing than the original. I have rejected it. Perhaps we can discuss a way to make this clearer here. – Post Rock Garf Hunter Jul 3 '17 at 16:40
• The worked examples are still very confusing - they seem to pull numbers out of nowhere, and each of the comparisons is expressed differently without explaining why certain numbers are used. If you already know the answer, you can figure it out . . . which I did by going back to the first paragraph, ignoring the examples until it was clear, then figuring out how the examples were constructed. Perhaps some tabular structure would help, also including 10 would probably help – Neil Slater Jul 3 '17 at 23:05
• @NeilSlater Thanks for the feedback. I've removed the examples entirely because I think they were doing more harm than good. I think the challenge is clear from the explanation, and the examples only complicate things. If the explanation is not sufficient I would be more than happy to expand or clarify on that, however I don't think I will be adding the examples back in because they seem to be the greatest source of confusion so far. – Post Rock Garf Hunter Jul 3 '17 at 23:26

# Jelly, 12 bytes

ÆRðfạṂ
Ç€M⁼W


Try it online!

### How it works

Ç€M⁼W   Main link. Argument: n

Ç€      Map the helper link over [1, ..., n].
M     Get all indices of the maximum.
W   Wrap; yield [n].
⁼    Test the results to both sides for equality.

ÆR      Prime range; get all primes in R := [1, ..., k].
ð     Begin a dyadic chain with arguments R and k.
ạ   Absolute difference; yield k-p for each p in R.
f    Filter; keep the q in R such that q = k-p for some p in R.
Ṃ  Take the minimum.
This yields 0 if the array is empty.


# PHP, 154 bytes

for(;$n++<$a=$argn;$i-1?:$p[]=$n)for($i=$n;--$i&&$n%$i;);foreach($p as$x)foreach($p as$y)if(!$r[$z=$x+$y]){$r[$z]=$x;$l[]=$z<$a?$x:0;};echo$r[$a]>max($l);  Try it online! Expanded for(;$n++<$a=$argn;$i-1?:$p[]=$n) # loop through all integers till input if is prime add to array for($i=$n;--$i&&$n%$i;);
foreach($p as$x) #loop through prime array
foreach($p as$y) #loop through prime array
if(!$r[$z=$x+$y]){
$r[$z]=$x; # add only one time lower value for a sum of$x+$y$l[]=$z<$a?$x:0;}; # add lower value if sum is lower then input echo$r[$a]>max($l); # Output 1 if lower value for sum of input is greater then all lower values of all numbers under input


Try it online! Check for all numbers till 1000

## JavaScript (ES6), 135 bytes

Uses a similar logic as Jörg's PHP answer.

(n,P=[...Array(n).keys()].filter(n=>(p=n=>n%--x?p(n):x==1)(x=n)))=>P.map(p=>P.map(q=>a[q+=p]=a[q]||(m=q<n&&p>m?p:m,p)),a=[m=0])&&a[n]>m


### Demo

let f =

(n,P=[...Array(n).keys()].filter(n=>(p=n=>n%--x?p(n):x==1)(x=n)))=>P.map(p=>P.map(q=>a[q+=p]=a[q]||(m=q<n&&p>m?p:m,p)),a=[m=0])&&a[n]>m

console.log(
JSON.stringify(
[...Array(310).keys()].filter(n => f(n))
)
)

# Python 3: 156151142138136 128 bytes

r=range
m=lambda n:min(x for x in r(2,n+1)if all(o%i for o in[x,n-x]for i in r(2,o)))
f=lambda n:m(n)>max(map(m,r(2,n,2)))or n<5


(thanks to OP)

(thanks to @Rod)(again)(and again)

• @Olmman do you like it? – enedil Jul 3 '17 at 19:07
• @Rod since max with key returns element with maximal value after applying key, I had to add function application but it's nonetheless shorter. – enedil Jul 3 '17 at 19:28
• @Rod and I can't take your suggestions as for range since n is bounded inside lambda. – enedil Jul 3 '17 at 19:30
• @enedil Indeed, but for the max, you can use max(map(m,r[::2])) – Rod Jul 3 '17 at 19:31
• You don't need to name f and thus can save 2 bytes by removing the f=. – Post Rock Garf Hunter Jul 3 '17 at 23:44

# Python 3: 204 196 bytes

Bytes saved thanks to: Olm Man

from itertools import*
m=lambda g:min([x for x in product([n for n in range(2,g)if all(n%i for i in range(2,n))],repeat=2)if sum(x)==g])
i=lambda g:1if all(m(g)>m(x)for x in range(4,g,2))else 0


Try it online!

• A few tips, most builtin functions like min and all can take generators as arguments, this means min([...]) can be shortened to min(...) and the same with all. You also can get rid of some spaces, particularly the space in import * and any space after braces, I see you have one after range(g) and one before [i for i in ..., neither are necessary. – Post Rock Garf Hunter Jul 3 '17 at 16:53
• ^That's awesome, I didn't know that – bendl Jul 3 '17 at 16:55
• Also you can make your prime check a little shorter by changing it to all(n%i for i in range(2,g)), but you have to change range(g) to range(1,g) because this gives a false positive on 1. – Post Rock Garf Hunter Jul 3 '17 at 17:02