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 ...
随机推荐
- 前端CSS规范整理_转载、、、
一.文件规范 1.文件均归档至约定的目录中. 具体要求通过豆瓣的CSS规范进行讲解: 所有的CSS分为两大类:通用类和业务类.通用的CSS文件,放在如下目录中: 基本样式库 /css/core 通用U ...
- NOIP2016普及
还记得去年局部变量忘记置零coin爆零的事......结果我今年又要考一年普及[趴 最近沉迷分块莫队无法自拔,这几天才想起来我是个普及组选手 几乎没准备普及,周六上午抱抱佛脚好了...... 希望能顺 ...
- spark 问题
问题描述1 使用spark-shell ,sc.textFile("hdfs://test02.com:8020/tmp/w").count 出现如下异常: java.lang.R ...
- 初探javascript
javascript是一种在网络广泛应用的脚本语言,虽然名字与java相近,但其实两者并没有直接的关系,脚本语言是一种为了便于操作和拓展功能而开发出来的解释性语言,不同于传统的编程语言,脚本语言不需要 ...
- MongoDB常用操作命令大全
成功启动MongoDB后,再打开一个命令行窗口输入mongo,就可以进行数据库的一些操作.输入help可以看到基本操作命令,只是MongoDB没有创建数据库的命令,但有类似的命令 如:如果你想创建一个 ...
- 4_jquery
官网:www.jquery.com 兼容: 1.jquery-3.1.0.js :form.attr("checked","false")无效 2.firefo ...
- 解决弹出的窗口window.open会被浏览器阻止的问题
问题现象 最近在做项目的时候碰到了使用window.open被浏览器拦截的情况,有时候会一直连接,有时候会偶尔拦截, 尝试了很多方法,走了很多弯路,总结一下结果分享大家 原因分析&深入研究 1 ...
- ios设备中openGL所支持的最大纹理尺寸
这几天碰到一个在iphone4上显示图片未黑色矩形的bug,在其他机器上都正常 最后发现是图片打包尺寸的关系,iphone4无法读取2048以上大小的单个图片,所以其中的图片都显示成了黑色,希望对碰到 ...
- Python之路Day21-自定义分页和cookie
本节知识点概要 1.URL 2.views - 请求其他信息 - 装饰器 3.Templates - 母版 - 自定义 4.Models操作 5.分页(自定义分页) 6.cookie 7.sessio ...
- mongodb的用户管理及安全认证
1.确认mongodb的版本 > use admin switched to db admin > db.runCommand({}) { "version" : &q ...