Godebach Conjecture of Algorithms

Source: Internet
Author: User
Using System; Namespace Test { Class Program { /// <Summary>          /// Determine the prime number          /// </Summary>          /// <Param name = "N"> </param>          /// <Returns> </returns>          Static   Bool Isprime ( Int N ){ Int J = ( Int ) Math. Ceiling (math. SQRT (convert. todouble (N ))); Bool Intflag = True ; For ( Int I = 1; I <= J; I ++ ){ If (N % I = 0 & (I! = 1) & (I! = N) {intflag = False ; Break ;}} Return Intflag ;} /// <Summary>         /// Enter a number to determine whether the result meets the Goldbach Conjecture.          /// An even number greater than 6 can represent the sum of two prime numbers.          /// </Summary>          /// <Param name = "N"> </param>          /// <Returns> </returns>          Static   Bool Isgdbharish ( Int N ){ Bool ISG = False ; If (N % 2 = 0 & n> 6 ){ For (Int I = 1; I <n/2; I ++ ){ Bool B1 = isprime (I ); Bool B2 = isprime (n-I ); If (B1 & B2) {console. writeline (" {0} = {1} + {2} ", N, I, n-I); ISG = True ;}}} Return ISG ;} Static   Void Main (String [] ARGs ){ ///// Prime Number              Int N = 1; While (N! =-1) {console. writeline (" Enter a number: "); If (Int32.tryparse (console. Readline (), Out N )){ If (N =-1) Break ; // If (program. isprime (n ))                      //{                     // Console. writeline ("{0} is a prime number", N );                      //}                      // Else                      //{                      // Console. writeline ("{0} is not a prime number", N );                      //} Isgdbharish (n) ;}} console. Readline ();}}}

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.