有关素数的几种不同的问题

//判断一个数是否是素数,是则yes否则no #include<iostream> #include<math.h> using namespace std; bool fun(int x) { int t=sqrt(x)+1;//注意,不要把sqrt放在循环条件中,否则每循环一次都会进行一次sqrt计算,时间复杂度会提高。 if(x<=1) return false; e
相关文章
相关标签/搜索