You are viewing a single comment's thread. Return to all comments →
string primality(int n) { bool flag = true; if(n == 1){ flag = false; } for(int i = 2; i <= sqrt(n); ++i){ if(n % i == 0){ flag = false; } } return flag ? "Prime" : "Not prime"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Time Complexity: Primality
You are viewing a single comment's thread. Return to all comments →