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 ...
随机推荐
- Asp.net MVC中Html.Partial, RenderPartial, Action,RenderAction 区别和用法(mvc部分视图的添加)
Partial 和RenderPartial:这两个的性质都是一样, 只指把一个个View给镶入进来, 只是回传值有点不一样Partial 回传的一个Object (MvcHtmlString), 回 ...
- 基于Proteus仿真的Arduino学习(2)——LED点阵探究A(LED点阵基础)
一.前言: 随着LED的普及,以LED点阵为基础的显示设置层出不穷.例如,公交车的线路提示牌.高速公路的信息提示牌,安装在大楼上的广告屏幕等.下面,我们将由简单到复杂地探索各种LED点阵的使用方法,同 ...
- 4.4 多线程进阶篇<下>(NSOperation)
本文并非最终版本,如有更新或更正会第一时间置顶,联系方式详见文末 如果觉得本文内容过长,请前往本人"简书" 本文源码 Demo 详见 Github https://github.c ...
- mysql_connect() php7不支持,php5.5可以,是废弃函数
天用了PHP7,发现和PHP5变化还挺大的,最大的就是MySQL的连接库变了. PHP5中使用mysql_connect()函数进行连接,但实际上,PHP5.5开始,MySQL就不推荐使用了,属于废弃 ...
- CC countari & 分块+FFT
题意: 求一个序列中顺序的长度为3的等差数列. SOL: 对于这种计数问题都是用个数的卷积来进行统计.然而对于这个题有顺序的限制,不好直接统计,于是竟然可以分块?惊为天人... 考虑分块以后的序列: ...
- 页面加载完成后,触发事件——trigger()
<button id="btn">点击我</button> <div id="test"></div> 如果页面 ...
- JQuery的一些简单功能
JQuery js的缺点总结 1.入口函数只能有一个,如果出现多个,后面的会覆盖掉前面的 2.代码容错性差,容易出错,出错会导致后面的代码不执行 3.存在浏览器兼容性,比如innerText在火狐浏览 ...
- Errors occurred during the build. Errors running builder 'JavaScript Validator' on project
1.问题:Errors occurred during the build. Errors running builder 'JavaScript Validator' on project 2.解决 ...
- 一、JSP、servlet、SQL三者之间的数据传递(前台与后台数据交互)
背景: 目前业界很流行的MVC(model-view-control)开发模式,理解为 模型是Bean, 视图是 Html/Jsp, 控制是Servlet, 关联数据库的Dao web的运行机制: 数 ...
- WCF自动添加消息头
客户端自定义消息查看器实现IClientMessageInspector接口在消息发送之前添加消息头 class ClientMessageInspector : System.ServiceMode ...