c++ - Built in prime checking function -
does c++ have built in function check if number prime or not. if yes, in library?
below implementation. looking if there built in function. searching on google gives user based implementations.
int isprime(int n){ if(n<2 || (!(n&1) && n!=2)) return 0; for(int i=3; i*i<=n; i+=2){ if(!(n%i)) return 0; } return 1; }
short answer: no, there's no such function.
the time word "prime" used in standard footnote in 26.5.3.2, mersenne_twister_engine class template described. footnote says:
274) name of engine refers, in part, property of period: properly-selected values of parameters, period closely related large mersenne prime number.
if such function existed, standard contain more occurrences of word, use describe behavior of function.
Comments
Post a Comment