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 ...
随机推荐
- leanote个人版安装
https://github.com/leanote/leanote/wiki/Leanote-%E4%BA%8C%E8%BF%9B%E5%88%B6%E7%89%88%E8%AF%A6%E7%BB% ...
- iterm2
Mac下配置iterm2 http://www.dreamxu.com/mac-terminal/ 快捷键 http://cnbin.github.io/blog/2015/06/20/iterm2- ...
- [BZOJ4197][Noi2015]寿司晚宴
4197: [Noi2015]寿司晚宴 Time Limit: 10 Sec Memory Limit: 512 MBSubmit: 412 Solved: 279[Submit][Status] ...
- java的基础知识运算符
一.运算符. 1.算数运算符:+,-,*,/,% 2.自增自减 :++ ,-- ++在前 先运算在赋值 ++在后 先赋值后运算 -- 减减同上. 3.赋值运算符 : = ,+=,-=,*=,/= 4. ...
- web前端笔试选择题
1. 要动态改变层中内容可以使用的方法有(AB ) a)innerHTML b)innerText c)通过设置层的隐藏和显示来实现 d)通过设置层的样式属性的display属性 2. 当按键盘A时, ...
- ubuntu的vim模式
之前想修改一个文件的内容,居然发现之前的东西又随着时间在空气中淡忘了,所以取了网上的一些摘文. 1.vim #在命令行中输入vim,进入vim编辑器 2. i #按一下i键,下端显示 --INSERT ...
- day 2 Linux基础
6.用户.群组和权限 1) 新建用户natasha,uid为1000,gid为555,备注信息为"master" useradd natasha usermod -u1000 na ...
- myeclipse tomcat内存溢出解决方法
Tomcat直接启动正常,通过myeclipse启动tomcat内存溢出.MyEclipse启动Tomcat无视catalina.bat中设置内存大小的问题.在 tomcat的catalina.bat ...
- 一篇关于匿名函数(function(){})()不错的文章
代码如下: (function(){ //这里忽略jQuery所有实现 })(); (function(){ //这里忽略jQuery所有实现 })(); 半年前初次接触jQuery的时候,我也像其他 ...
- 如何将Eclipse中的项目迁移到Android Studio 中
如何将Eclipse中的项目迁移到Android Studio 中 如果你之前有用Eclipse做过安卓开发,现在想要把Eclipse中的项目导入到Android Studio的环境中,那么首先要做的 ...