Godebach conjecture C #

Source: Internet
Author: User
I don't know why in the past two days. I have always been thinking about some childhood problems. I remember that godbach's conjecture was a mysterious theory when I was a child. Now I want to think about it again, I will use C # To implement it. I will post it for everyone to study. I will discuss some good suggestions: I cannot implement a problem here, it is the infinite representation of computers. to thoroughly prove this theory, I think I still have to use the infinite representation, which is not something I can prove, it is not estimated that my computer can afford the load. Using system;
Using system. Collections. Generic;
Using system. Text; namespace godebach Conjecture
{
Class Program
{
Static void main (string [] ARGs)
{
// The Golden Bach conjecture can be roughly divided into two conjecture types:
// 1. Each even number not less than 6 can be expressed as the sum of two odd prime numbers;
// 2. Each odd number not less than 9 can be expressed as the sum of the three odd prime numbers. Int number;
Try
{
// Input cyclically
For (;;)
{
Console. writeline ("The Golden Bach conjecture can be roughly divided into two guesses :");
Console. writeline ("1. Each even number not less than 6 can be expressed as the sum of two odd prime numbers ;");
Console. writeline ("2. Each odd number not less than 9 can represent the sum of three odd prime numbers. ");
Console. Write ("enter a number greater than 7 at will:" + "/N"); // receive keywords
Number = int. parse (console. Readline (); // determines whether it is the first theorem or the second theorem of the Golden Bach conjecture. If (number> = 6 & Number % 2 = 0)
{

// Console. Write (number );
// Console. Write (math. SQRT (number ));
// Console. Write (isprimenumber (number ));
// Console. Write ("/N ");
// Isprimenumber (number );
Expression_1 (number );
// Oushu (number );
}
Else
{
If (number> = 9 & Number % 2 = 1)
{
Expression_2 (number );
}
Else
{
Console. writeline ("incorrect input ");
Break;
}
}}
}
Catch (exception)
{
Console. writeline ("You are not entering a number. Please enter a number ·····");
} // After entering a number, output all the even numbers and expressions that are less than the first theorem.
Public static bool oushu (INT m)
{
Bool Yes = false; For (INT I = 0; I <= m; I ++)
{
If (I % 2 = 0 & I> 6)
{
Console. writeline ("even" + I + "can be expressed :");
Console. Write ("/N ");
Expression_1 (I );
Yes = true;
}
}
Return yes;
} // Judge the prime number and output it as an expression
Public static bool expression_1 (int n)
{
Bool Yes = false;
If (N % 2 = 0 & n> 6)
{
For (INT I = 1; I <= n/2; I ++)
{
Bool b1 = isprimenumber (I); // checks whether I is a prime number.
Bool b2 = isprimenumber (n-I); // determines whether N-I is a prime number.
If (B1 & B2)
{
Console. writeline ("{0 }={ 1} + {2}", N, I, n-I );
Console. Write ("/N ");
Yes = true;
}
}
}
Return yes;
} // Simple Proof Method Supporting the second theorem
Public static bool expression_1_1 (int n)
{
Bool Yes = false;
If (N % 2 = 0 & n> 6)
{
Yes = true;
}
Return yes;
} // Prove the second theorem and output the expression
Public static bool expression_2 (INT m)
{
Bool Yes = false;
If (M> 9 & M % 2 = 1)
{
For (INT I = 1; I <= m/2; I ++)
{
Bool b1 = isprimenumber (I );
// Bool b2 = expression_1_1 (M-I );
For (Int J = 1; j <I/2; j ++)
{
Bool b2 = isprimenumber (j );
Bool B3 = isprimenumber (M-I-j );
If (B1 & B2 & B3)
{
Console. writeline ("{0 }={ 1} + {2} + {3}", M, I, j, M-I-j );
Console. writeline ("/N ");
Yes = true;
}
}
}
} Return yes;
} // Determine the prime number
Public static bool isprimenumber (INT m)
{
Bool Yes = false; Int J = 2; for (; j <= math. SQRT (m); j ++)
{
If (M % J = 0)
{
Return yes;
} Return YES = true;
}
}
}

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.