/*
- 问题:四胞胎素数是指一组大于3且满足{p, p+2, p+6, p+8}的四个连续素数。
- 头几组四胞胎素数如下{5, 7, 11, 13}, {11, 13, 17, 19}, {101, 103, 107, 109}, {191, 193, 197, 199}, {821, 823, 827, 829}。
- 请问1000000以内有多少组四胞胎素数?
*/
public class Ahalei {
public static void main(String[] args) {
int[][] a = new int[1000001][2];
int[] b = new int[1000000];
int Num = 1000000;
for(int i=1; i<=Num; i++){
a[i][0] = i;
a[i][1] = 0;
}
for(int i=2; i<=Math.sqrt(Num); i++){
for(int j=2; j<=Num/2; j++){
if(i*j<=Num){
a[i*j][1] = 1;
}
}
}
int j=0;
for(int i=2; i<=Num; i++){
if(a[i][1]==0)
b[j++] = a[i][0];
}
int n=0;
for(int i=3; i<b.length; i++)
if(b[i]+b[i-1]+b[i-2]+b[i-3]==b[i-3]*4+16)
System.out.println(b[i-3]+" "+b[i-2]+" "+b[i-1]+" "+b[i]+" "+ ++n);
}
}