日期:2014-05-20 浏览次数:20754 次
public class PalindromicPrime {
public static void main(String[] args){
int mark = 1;
while(mark != 100){
for(int i =1; mark != 100; i++){
if(isPlaindrome(i) && isPrime(i)){
System.out.println(i+"/t");
if(mark % 10 ==0)
System.out.println("/t");
mark++;
}
}
}
}
public static boolean isPlaindrome(int num){
int [] number = new int[20];
int num1 =num;
for(int i = 0;i<20;i++){
number[i] = 1;
}
if(num < 10)
return true;
else {
int mark;
for(int i=1;number[i-1]!=0;i++){
number[i-1] = num1 %10;
num = num /10;
}
int i =number.length;
number[i-1] = num1/(int)Math.pow(10, i);
for(int n=i,m=0;m<i/2;n--,m++){
if(number[m] == number [n-1])
mark++;
}
if(mark == i/2)
return true;
}
boolean isPrime(int m){
int mark =0;
for(int i=1 ; i < m /2 ;i++){
if(m % i == 0 && i!= 1 && i!= m)
mark =1;
}
if(mark !=1)
return true;
else
return false;
}
}
}
package fromnet;
public class PalindromicPrime {
public static void main(String[] args) {
int mark = 1;
while (mark != 100) {
for (int i = 1; mark != 100; i++) {
if (isPlaindrome(i) && isPrime(i)) {