0
How to fine prime number in C++ using easy code?
I wanna learn to find prime number using c++
3 odpowiedzi
+ 1
//Lengthy? As in code length or time?? In coding, you need to sacrifice readability for shorter length. So if you want shorter it will be less readable.
//Ps. You can use recursion for "shorter length"
bool isprime(int n,int i){
if(n%i==0){
if(i==1) return true;
else return false;
}
else return isprime(n,i-1);
}
Where i=sqrt(n)
0
its lengthy code