HW5.27

public class Solution
{
public static void main(String[] args)
{
int totalCount = 0;
int lineCount = 0;
int i = 2;
while(true)
{
if(isPrime(i) && (isPrime(getReverse(i))))
{
System.out.printf("%d\t", i);
totalCount++;
lineCount++;
}
i++;
if(lineCount == 10)
{
lineCount = 0;
System.out.println();
}
if(totalCount == 100)
break;
}
}
public static boolean isPrime(int number)
{
if(number == 1)
return false;
else if(number == 2)
return true;
else
{
for(int i = 2; i < number; i++)
{
if(number % i == 0)
return false;
}
return true;
}
}
public static int getReverse(int number)
{
String str = "";
if(number < 10)
str += number;
else
str += number % 10 + "" + getReverse(number / 10);
return Integer.parseInt(str);
}
}
HW5.27的更多相关文章
- CSharpGL(27)讲讲清楚OpenGL坐标变换
CSharpGL(27)讲讲清楚OpenGL坐标变换 在理解OpenGL的坐标变换问题的路上,有好几个难点和易错点.且OpenGL秉持着程序难以调试.难点互相纠缠的特色,更让人迷惑.本文依序整理出关于 ...
- Amazon Interview | Set 27
Amazon Interview | Set 27 Hi, I was recently interviewed for SDE1 position for Amazon and got select ...
- CentOS7 编译安装LVS 互为主备 (实测 笔记 Centos 7.0 + ipvsadm 1.27 + keepalived 1.2.15 )
环境: 系统硬件:vmware vsphere (CPU:2*4核,内存2G,双网卡) LVS服务器(两台): 系统:Centos7.0 64位(LVS+keepalived) LvsMaster:1 ...
- ORA-12899: value too large for column (actual: 27, maximum: 20)
导入数据时报错以下错误,这是因为原来的数据库是GBK的,每个汉字两个字节,但新数据库是UTF-8的,每个汉字是三个字节,导致超过长度了. ORA-12899: value too large for ...
- 背水一战 Windows 10 (27) - 控件(文本类): TextBlock
[源码下载] 背水一战 Windows 10 (27) - 控件(文本类): TextBlock 作者:webabcd 介绍背水一战 Windows 10 之 控件(文本类) TextBlock 示例 ...
- Internet Download Manager 6.27.1 中文特别版(IDM)
软件介绍: 软件名称:Internet Download Manager(IDM) 软件大小:5.09M软件语言:简体中文 软件官网:http://www.internetdownloadmanage ...
- CentOS6.3 编译安装LAMP(4):编译安装 PHP5.3.27
所需源码包: /usr/local/src/PHP-5.3.27/libmcrypt-2.5.8.tar.gz /usr/local/src/PHP-5.3.27/mhash-0.9.9.9.tar. ...
- NYOJ题目27水池数目
--------------------------------------------- 这道题有点坑,也怪我总是有点马虎,按照正常人的思维0是表示有水池啊竟然是1表示有水池,最坑的是写反了竟然还能 ...
- 腾讯QQ认证空间4月27日已全面开放申请,欲进军自媒体
今天看到卢松松的博客上爆出,腾讯QQ认证空间4月27日已全面开放申请的消息,这一消息出来, 马浩周根据提示方法进行申请,下面先说说腾讯QQ认证空间的申请方法: QQ认证空间开放申请公告地址:http: ...
随机推荐
- Samza文档翻译 : Comparison Introduction
http://samza.incubator.apache.org/learn/documentation/0.7.0/comparisons/introduction.html 这里有一些使得Sam ...
- HDU4602+推导公式
手动列出前5项 可发现规律 /* 推导公式 a[n] = 2^(n-1) + (n-2)*2^(n-3) */ #include<stdio.h> #include<math.h&g ...
- samba配置smb.conf
[share] path = /home/phinecos/share available = yes browsealbe = yes public = ye ...
- ANDROID_MARS学习笔记_S01_012_SeekBar
1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...
- MSSQLServer基础04(常用函数)
类型转换函数 CAST ( expression AS data_type) CONVERT ( data_type, expression,[style]) 对日期的转换.转换成各种国家格式的日期. ...
- ColorBox常见问题
发现colorbox官方网站的troubleshoot写的比较好,转载一下. 1,flash覆盖colorbox: This is not a ColorBox specific problem, b ...
- git源码中的Makefile
https://github.com/chucklu/GitStudy 这链接里面的第一次提交 [chucklu@localhost GitStudy]$ cat Makefile CFLAGS= ...
- Android开发UI之手动显示和隐藏软键盘
1.方法一(如果输入法在窗口上已经显示,则隐藏,反之则显示) InputMethodManager imm = (InputMethodManager) getSystemService(Contex ...
- jekyll themes
jekyll主题下载: https://mademistakes.com/work/jekyll-themes/ https://github.com/jekyll/jekyll/wiki/Theme ...
- 比较const ,readonly, stitac readonly
比较const ,readonly, stitac readonly: const和readonly的值一旦初始化则都不再可以改写: const必须在声明时初始化:readonly既可以在声明时初始化 ...