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

  • \$\begingroup\$ Let us continue this discussion in chat. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 3, 2017 at 14:31
  • \$\begingroup\$ 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. \$\endgroup\$ Commented Jul 3, 2017 at 16:38
  • 1
    \$\begingroup\$ @ЕвгенийНовиков I found your edit more confusing than the original. I have rejected it. Perhaps we can discuss a way to make this clearer here. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 3, 2017 at 16:40
  • \$\begingroup\$ 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 \$\endgroup\$ Commented Jul 3, 2017 at 23:05
  • \$\begingroup\$ @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. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 3, 2017 at 23:26

5 Answers 5


Jelly, 12 bytes


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ðfạṂ  Helper link. Argument: k

Æ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!


for(;$n++<$a=$argn;$i-1?:$p[]=$n) # loop through all integers till input if is prime add to array 
foreach($p as$x) #loop through prime array
  foreach($p as$y) #loop through prime array 
      $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.



let f =


    [...Array(310).keys()].filter(n => f(n))


Python 3: 156 151 142 138 136 128 bytes

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)

  • \$\begingroup\$ @Olmman do you like it? \$\endgroup\$
    – enedil
    Commented Jul 3, 2017 at 19:07
  • \$\begingroup\$ @Rod since max with key returns element with maximal value after applying key, I had to add function application but it's nonetheless shorter. \$\endgroup\$
    – enedil
    Commented Jul 3, 2017 at 19:28
  • \$\begingroup\$ @Rod and I can't take your suggestions as for range since n is bounded inside lambda. \$\endgroup\$
    – enedil
    Commented Jul 3, 2017 at 19:30
  • \$\begingroup\$ @enedil Indeed, but for the max, you can use max(map(m,r[::2])) \$\endgroup\$
    – Rod
    Commented Jul 3, 2017 at 19:31
  • 1
    \$\begingroup\$ You don't need to name f and thus can save 2 bytes by removing the f=. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 3, 2017 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][0])
i=lambda g:1if all(m(g)>m(x)for x in range(4,g,2))else 0

Try it online!

  • 2
    \$\begingroup\$ 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. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 3, 2017 at 16:53
  • \$\begingroup\$ ^That's awesome, I didn't know that \$\endgroup\$
    – bendl
    Commented Jul 3, 2017 at 16:55
  • \$\begingroup\$ 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. \$\endgroup\$
    – Wheat Wizard
    Commented Jul 3, 2017 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.