C#实现哥德巴赫猜想
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#实现哥德巴赫猜想的更多相关文章
- *CF2.D(哥德巴赫猜想)
D. Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input outp ...
- code forces 382 D Taxes(数论--哥德巴赫猜想)
Taxes time limit per test 2 seconds memory limit per test 256 megabytes input standard input output ...
- CF735D Taxes 哥德巴赫猜想\判定素数 \进一步猜想
http://codeforces.com/problemset/problem/735/D 题意是..一个数n的贡献是它的最大的因子,这个因子不能等于它本身 然后呢..现在我们可以将n拆成任意个数的 ...
- 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 ...
- Codeforces 735D:Taxes(哥德巴赫猜想)
http://codeforces.com/problemset/problem/735/D 题意:给出一个n,这个n可以分解成 n = n1 + n2 + -- + nk,其中k可以取任意数.要使得 ...
- LightOJ 1259 Goldbach`s Conjecture (哥德巴赫猜想 + 素数筛选法)
http://lightoj.com/volume_showproblem.php?problem=1259 题目大意:给你一个数n,这个数能分成两个素数a.b,n = a + b且a<=b,问 ...
- 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 ...
- 哥德巴赫猜想证明(C语言实现50以内的正偶数证明)
<一>哥德巴赫猜想内容: 一个充分大的偶数(大于或等于6)可以分解为两个素数之和. <二>实现要点: 要点: 判断素数(质数):除了1和本身没有其他约数. 最小的质数:2 判断 ...
- c语言验证哥德巴赫猜想(从4开始 一个偶数由两个质数之和)
#include <stdio.h> #include <stdlib.h> #include <math.h> int isit(int num) { int i ...
随机推荐
- js 怎么屏蔽微信打开网页后的分享
我们知道 js 可以通过 window.navigator.userAgent 来获取浏览器的相关信息,比如:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537. ...
- 【转】apache 二级域名设置完整步骤
原文链接:http://blog.sina.com.cn/s/blog_5375d76b01014fnt.html 最近在折腾网站二级域名的事情,在网上查了很多零碎的文档,不完整,有些也没有自己验证, ...
- ACM: Gym 101047M Removing coins in Kem Kadrãn - 暴力
Gym 101047M Removing coins in Kem Kadrãn Time Limit:2000MS Memory Limit:65536KB 64bit IO Fo ...
- *HDU1850 博弈
Being a Good Boy in Spring Festival Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32 ...
- angularjs服务-service
Service 的特性 ①service都是单例的 ②service由$injector 负责实例化 ③service在整个应用的声明周期中存在,可以用来共享数据 ④在需要使用的地方利用依赖注入ser ...
- final 评论ii
按照演讲顺序 1.约跑app 约跑app,从界面的单调,到最后的final发布,实现界面的友好性,有了很大的提高.约跑app,如果在约定地点可以显示出,所在位置,以及约定地址.就可以达 ...
- 一鼓作气 博客--第六篇 note6
1.无论公司付给你多少,你的青春都是廉价的!! 2.通往财富自由之路 --得到APP 3.time 3.1 time.time() t = time.time() print(t) #--->1 ...
- android中webview调用拨号盘
wv.setWebViewClient(new WebViewClient(){ public boolean shouldOverrideUrlLoading(WebVie ...
- 使用java反射机制编写Student类并保存
定义Student类 package org; public class Student { private String _name = null; ; ; public Student() { } ...
- linux内核分析作业5:分析system_call中断处理过程
1.增加 Menu 内核命令行 调试系统调用. 步骤:删除menu git clone (tab) make rootfs 这就是我们将 fork 函数写入 Menu 系统内核后的效果, ...