bool prime(int n){ int i = 7, j, q; if(n == 1) return false; if(n == 2 || n == 5 || n == 3) return true; if(n % 2 == 0 || n % 3 == 0 || n % 5 == 0) return false; q = (int)sqrt((double)n); for(; i <= q; ){ for(j = 0; j < 8; ++j){ if(n % i == 0) return false; i += p[j]; } if(n % i == 0) return false; } return true;}