0

I have been reading up on Goldbach's conjecture and how I understand it is as follows:

For all values of x that satisfy x % 2 == 0, where x is an element from the set of natural numbers starting at 4, x is the sum of 2 primes numbers

I was wondering is this also true?: For all values of x that satisfy x % n == 0, where x is an element from the set of natural numbers starting at n * 2, x is the sum of n primes numbers

I wrote a quick program to test this theory and so far it hasnt failed:

static int[] prime_bank;

public static void main(String[] args) { int size = 500; fillBank(size); int result; for(int i = 2; i < 100; ++i) if((result = isValidGoldBach(size, i)) == -1){ System.out.println("Valid GoldBach at:" + i); }else{ System.out.println("Invalid GoldBach at:" + i + " (number:" + result + ")"); } }

private static int isValidGoldBach(int max_value, int div){ for(int i = div * 2; i < max_value; i += div){ if(!checkGoldBach(i, div)) return i; } return -1; }

private static boolean _checkGoldBach(int number, int div, int curr, int[] buffer){ if(curr < div){ for (int i : prime_bank) { buffer[curr] = i; if(_checkGoldBach(number, div, curr + 1, buffer)) return true; } }else{ int sum = 0; for(int i : buffer)sum += i; return sum == number; } return false; }

private static boolean checkGoldBach(int number, int div){ return _checkGoldBach(number, div, 0, new int[div]); }

private static void fillBank(int size){ prime_bank = new int[size]; if(size > 0) prime_bank[0] = 2; int idx = 1; for(int i = 3; idx < size; i += 2){ if(isPrime(i)){ prime_bank[idx++] = i; } } }

private static boolean isPrime(int n){ int sqrt = (int) Math.ceil(Math.sqrt(n)); if(n % 2 == 0) return false; for(int i = 3; i < sqrt; i += 2){ if(n % i == 0) return false; } return true; }

My question is, does this hold true (obviously since the Goldbachs conjecture hasnt been proven yet I am not wondering about a proof, just if this is true for a large data set) or did I write my program wrong?

  • 2
    Well if you believe Goldbach then every natural number is the sum of at most $3$ primes (maybe excluding some very small counterexamples). After all, either $n$ or $n-3$ is even. – lulu Jul 22 '21 at 18:07
  • It has been proven that every odd number greater then $5$ is the sum of three primes. Therefore, for sufficiently large numbers, the case $n\ge 4$ is done. Not sure about the case $n=3$ – Peter Jul 22 '21 at 18:08
  • 1
    @Peter "Sufficiently large" can be quantified: If $n\ge 4$ and $x\ge 2n-1$, then $x$ is the sum of $n$ primes (because $x-(n-3)\cdot 2\ge 5$) – Hagen von Eitzen Jul 22 '21 at 18:12
  • @Peter can you provide a reference for that, it sounds interesting! – Curious_Student Jul 22 '21 at 18:15
  • The case $n=3$ for numbers greater than $5$ works if and only if the Goldbach conjecture is true. – Peter Jul 22 '21 at 18:16

0 Answers0