using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GoetheOfArithmetic
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("请输入一个大于6的偶数:");
            int intNum = Convert.ToInt32(Console.ReadLine());
            bool blFlag = ISGDBHArith(intNum);
            if (blFlag)
            {
                Console.WriteLine("{0}能写成两个素数的和,所以其符合哥德巴赫猜想。", intNum);
            }
            else
            {
                Console.WriteLine("猜想错误");
            }
            Console.ReadLine();
        }

        static bool ISGDBHArith(int intNum)
        {
            bool blFlag = false;
             ==  && intNum > )
            {
                ; i < intNum / ; i++)
                {
                    bool bl1 = IsPrimeNumber(i);
                    bool bl2 = IsPrimeNumber(intNum - i);

                    if (bl1 & bl2)
                    {
                        Console.WriteLine("{0}={1}+{2}", intNum, i, intNum - i);
                        blFlag = true;
                    }
                }
            }

            return blFlag;
        }

        static bool IsPrimeNumber(int intNum)
        {
            bool blFlag = true;
             || intNum == )
            {
                blFlag = true;
            }
            else
            {
                int sqr = Convert.ToInt32(Math.Sqrt(intNum));
                ; i--)
                {
                    )
                    {
                        blFlag = false;
                    }
                }
            }
            return blFlag;
        }
    }
}

C#实现哥德巴赫猜想的更多相关文章

  1. *CF2.D(哥德巴赫猜想)

    D. Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...

  2. code forces 382 D Taxes(数论--哥德巴赫猜想)

    Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...

  3. CF735D Taxes 哥德巴赫猜想\判定素数 \进一步猜想

    http://codeforces.com/problemset/problem/735/D 题意是..一个数n的贡献是它的最大的因子,这个因子不能等于它本身 然后呢..现在我们可以将n拆成任意个数的 ...

  4. Codeforces Round #382 (Div. 2) D. Taxes 哥德巴赫猜想

    D. Taxes 题目链接 http://codeforces.com/contest/735/problem/D 题面 Mr. Funt now lives in a country with a ...

  5. Codeforces 735D:Taxes(哥德巴赫猜想)

    http://codeforces.com/problemset/problem/735/D 题意:给出一个n,这个n可以分解成 n = n1 + n2 + -- + nk,其中k可以取任意数.要使得 ...

  6. LightOJ 1259 Goldbach`s Conjecture (哥德巴赫猜想 + 素数筛选法)

    http://lightoj.com/volume_showproblem.php?problem=1259 题目大意:给你一个数n,这个数能分成两个素数a.b,n = a + b且a<=b,问 ...

  7. Codeforces Round #324 (Div. 2) D. Dima and Lisa 哥德巴赫猜想

    D. Dima and Lisa Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/584/probl ...

  8. 哥德巴赫猜想证明(C语言实现50以内的正偶数证明)

    <一>哥德巴赫猜想内容: 一个充分大的偶数(大于或等于6)可以分解为两个素数之和. <二>实现要点: 要点: 判断素数(质数):除了1和本身没有其他约数. 最小的质数:2 判断 ...

  9. c语言验证哥德巴赫猜想(从4开始 一个偶数由两个质数之和)

    #include <stdio.h> #include <stdlib.h> #include <math.h> int isit(int num) { int i ...

随机推荐

  1. 代码在ie9中不能正确执行

    <!DOCTYPE html> <html> <head lang="zh"> <meta charset="UTF-8&quo ...

  2. AR初体验:宣传G20

    最近Pokemon Go太火,它基于LBS(Location Based Service)+AR(Augmented Reality)的一款游戏,这股风,一定会让国内的公司纷纷效仿,你懂的.不可否定的 ...

  3. 还原后缀名为.bak的数据库备份文件

    1.打开SQL Server Management Studio,随便右击击一个数据库选择任务-->还原-->数据库 4.在弹出来的窗口中的源选项中选择设备-->点选择设备--> ...

  4. 扩展BindingList,防止增加、删除项时自动更新界面而不出现“跨线程操作界面控件 corss thread operation”异常

    在做界面程序时,常常需要一些数据类,界面元素通过绑定等方式显示出数据,然而由于UI线程不是线程安全的,一般都需要通过Invoke等方式来调用界面控件.但对于数据绑定bindingList而言,没法响应 ...

  5. network issue troubleshooting

    Today we troubleshooting a lot of network issue by using commands like: ping <ip>/<computer ...

  6. python列表副本

    a=[1,2,3] b=[4,5,6] a=a+b #创建含a和b的副本的新列表 a [1, 2, 3, 4, 5, 6] b [4, 5, 6] c=a+b #创建含a和b的副本的新列表c [1, ...

  7. (转)python requests的安装与简单运用

    requests是python的一个HTTP客户端库,跟urllib,urllib2类似,那为什么要用requests而不用urllib2呢?官方文档中是这样说明的: python的标准库urllib ...

  8. java包(package)的命名规范

     Java的包名都有小写单词组成,类名首字母大写:包的路径符合所开发的 系统模块的 定义,比如生产对生产,物资对物资,基础类对基础类.以便看了包名就明白是哪个模块,从而直接到对应包里找相应的实现. 由 ...

  9. jvm的内存分配总结

    最近看了周志明版本的<深入理解Java虚拟机>第一版和第二版,写的很好,收获很多,此处总结一下.   jvm中内存划分:   如上图,一共分为五块,其中: 线程共享区域为: 1.java堆 ...

  10. 如何生成报告来枚举出整个sharepoint环境中的每个页面所使用的所有webpart

    背景 我的公司的SharePoint环境中购买了大量的第三方webpart,比如Quick Apps, Telerik RadEditor, Nintex Workflow等等..这样做的好处就是成本 ...