算法筆記5.4 數學問題->素數 普通做法 埃式篩法

1.判斷素數 bool isPrime(int n){ int sqr=(int)sqrt(1.0*n); for(int i=2;i<=sqr;i++){ if(n%i==0) return false; } return true; } #include<iostream> #include<cmath> using namespace std; bool isPrime(
相關文章
相關標籤/搜索