Proof of godebach's Conjecture

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.