C#实现哥德巴赫猜想
2024-08-25 04:56:24
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; } } }
最新文章
- PHP文件相关的操作函数——文件操作
- AS 重装系统之后配置
- 用maven搭建 testNG+PowerMock+Mockito测试框架
- C primer plus 练习题 第六章
- js上传图片预览
- SSL证书请求文件(CSR)生成指南 - Tomcat
- Ubuntu 14.10 下Ganglia监控Spark集群
- for语句中声明变量
- Cocos2d-x实例:设置背景音乐与音效-HelloWorld场景实现
- Comparator和Comparable
- 锁和监视器之间的区别 – Java并发
- Xshell Linux 主要命令
- JDK1.8下载与安装及环境变量配置
- man sm-notify(sm-notify命令中文手册)
- h5笔记02
- requests 使用免费的代理ip爬取网站
- C#集合类型大揭秘
- FileZilla建立服务器,命令行客户端
- 【转】keil5 missing close quote 错误解决
- 微信小程序插件内页面跳转和参数传递(转)
热门文章
- org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launch IE
- 【原】iOS学习之应用之间的操作
- PHPer不能不看的50个细节!
- 使用IHTMLDocument2解决弹出";为了让该网站给你提供个人化信息,是否允许在你计算机放置cookie?";
- 树形DP
- Shader实例:序列帧动画
- 【ORACLE】字符串操作 B字符串时A的一部分
- tomcat -ROOT 与webapps 的关系,关于部署的一些问题
- ts 协议解析
- 无法连接虚拟设别 ide1:0.