求循环素数
来源:互联网 发布:手机笑声音效软件 编辑:程序博客网 时间:2024/05/22 18:22
这里只是以求三位循环素数为例子。
public class CirclePrimeNumber{public static boolean isPrime(int n){for (int i = 2; i <= Math.sqrt(n); i++){if (n % i == 0){return false;}}return true;}public static int circle(int n){int a = n % 10;int b = n / 10;return a * 100 + b;}public static void main(String[] args){int count = 0;int temp = 0;for (int i = 999; i >= 100; i--){count = 0;temp = i;for (int j = 1; j <= 3; j++){if (isPrime(temp)){count++;temp = circle(i);}else {break;}}if (count == 3){System.out.println(i);}}}}
可以参考点击打开链接
0 0
- 求循环素数
- 利用java中的双层循环求素数
- 用foe循环求100到200之间的素数
- 蓝桥杯:求一个5位数的最大循环素数
- 三种循环语句以及求绝对值 素数
- 利用for循环求100~200内的素数
- 循环素数
- 循环素数
- 循环素数
- 蓝桥杯:求一个5位数的最大循环素数和 回文素数
- 求素数
- 求素数
- 求素数
- 求素数
- 求素数
- 求素数
- 求素数
- 求素数
- android导入eclipse项目后,gradle版本引起的问题
- hibernate异常:解决Hibernate的Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL):
- 百度地图getAddrStr()方法返回为空的问题
- uva 11077 - Find the Permutations(置换+dp)
- 美元兑人民币汇率对黄金价格的预测
- 求循环素数
- Block的循环引用问题
- Android导航菜单横向左右滑动并和上方的控件实现联动
- 没有iptables文件的情况,防火墙开启3306端口
- Python heapq模块
- Linux编写Shell脚本自动同步svn并发布maven项目-SSH连接远程服务
- 面向对象与面向过程区别
- #pragma arm section
- MongoDB分片实战