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 ...
随机推荐
- LeetCode 389. Find the Difference
Given two strings s and t which consist of only lowercase letters. String t is generated by random s ...
- TF-IDF算法确定阅读主题词解答英语阅读Title题目
#include <math.h> #include <time.h> #include <stdlib.h> #include <iostream> ...
- 为Python安装pymssql模块来连接SQLServer
1.安装依赖包 yum install -y gcc python-devel 2.安装freetds 下载地址:http://pan.baidu.com/s/1pLKtFBl tar zxvf fr ...
- bzoj2342还是马拉车
就好比第一次写主席树的时候写了30行,第二次写了5行 这次马拉车只剩下 ,id=,mx=;i<=n;i++) { -i],mx-i):;a[i-p[i]]==a[i+p[i]+];p[i]++) ...
- 【Linux】crontab 定时任务
7月份,公司海外运营国发生数据库联接未释放,造成连接池连接不足的情况, 当时查询并没有及时解决问题, 为了避免现场同事多次人工重启系统的,因此写了个shell脚本,通过crontab 实现系统重启,但 ...
- 第三周作业(三):wc程序
本程序实现了统计文本档案中,文本单词数.字符数以及行数. 代码如下: #include<stdio.h> #include<stdlib.h> int linestatisti ...
- 阮一峰对js的见解(10大缺陷)
一.为什么Javascript有设计缺陷?这里有三个客观原因,导致Javascript的设计不够完善.1. 设计阶段过于仓促Javascript的设计,其实只用了十天.而且,设计师是为了向公司交差,本 ...
- web前端面试题汇总
1.doctype作用 <!DOCTYPE>声明位于位于HTML文档中的第一行,处于 <html> 标签之前.告知浏览器的解析器用什么文档标准解析这个文档.DOCTYPE不存在 ...
- CSS垂直水平居中方法总结
在布局的时候经常能用到居中,在此总结一下 html结构: <div class="wrap"> <div class="content"> ...
- Spring AOP实例——异常处理和记录程序执行时间
实例简介: 这个实例主要用于在一个系统的所有方法执行过程中出线异常时,把异常信息都记录下来,另外记录每个方法的执行时间. 用两个业务逻辑来说明上述功能,这两个业务逻辑首先使用Spring AOP的自动 ...