1 package codeTask_FangFa;
 2 // 5.30     双素数就是两个相差为2的素数。程序显示所有小于1000的双素数。按照格式显示。
 3 public class ShuangSuShu {
 4     public static void main(String[] args){           //所谓的主方法;
 5         int number = 3;
 6         int first = 2;
 7         System.out.println("前1000以内的双素数为:" );
 8         while(number<1000){
 9             if(isSuShu(number)){
10                 int second = number;
11                 if(second-first==2){
12                    System.out.println("( "+first+","+second+" )");
13                 }
14                 first=second;
15             }
16             number++;
17         }
18     }
19     
20     public static boolean isSuShu(int number){                   //判断下是否是素数;
21         for(int divisor=2;divisor<=number/2;divisor++){
22             if(number%divisor==0)
23             return false;    
24         }
25         return true;
26     }
27     
28 }