Public class guess {public static Boolean isprime (int I) {// checks whether the parameter I is a prime number. If yes, returns true; otherwise, returns false int N; Boolean flag = true; if (1 = I) // 1 itself is not a prime number, so you need to throw this special number flag = false; For (n = 2; n <= I-1; N ++)/* One way to determine whether I is a prime number is to see 2 ~ There is a factor between the I-1 (can be divisible by 2), if not a prime number returns false, Otherwise returns true */if (I % N = 0) {flag = false; break;} return flag;} public static Boolean isgoldbach (int A) {// determines whether parameter a complies with the int I of the godebach conjecture; Boolean flag = false; for (I = 1; I <= A/2; I ++) {If (isprime (I) & isprime (a-I) {// based on the expression in the question analysis, the two parameters flag = true; // system. out. print (a + "=" + I + "+" + (a-I) + ""); system. out. printf ("% 3d = % 3d + % 3d", A, I, (a-I); break; // Exit the loop as long as there is a qualified one and judge the next even number} return flag;} public static Boolean testify_guess (INT low, int high) {// Judge 1 ~ Whether all the even numbers in the range of 100 comply with the godebach conjecture, true is returned, and false int I, j = 0; Boolean flag = true; for (I = low; I <= high; I ++) if (I % 2 = 0 & I> 2 ~ 200 select an even number greater than 2 for conjecture test if (isgoldbach (I) {J ++; // J is used to control the output format, each row outputs 5 data if (j = 10) {system. out. println (); j = 0 ;}} else {flag = false; break;} return flag;} public static void main (string [] ARGs) {system. out. println ("\ n in 1 ~ In the range of 200, it is now verified that the godebach conjecture: "); If (testify_guess (1, 2000000000) {system. Out. println (" \ n is in 1 ~ In the range of 200, the golden Bach conjecture is correct. ") ;}Else {system. Out. println (" \ n godebach's conjecture is wrong ");}}}
Proof of godebach's Conjecture