Write an algorithm to find whether given number is prime or not.
Prime number is positive integer, which is divisible by itself and 1.
lgorithm:
Answers
Answered by
0
Explanation:
I can't grant you that this algorithm must work, but it should work nicely.
Sorry, I can't explain as brainly doesn't supports that much words.
int n;
cin>>n;
bool is_all_condition_true=false;
if (n%11! = 0)
{ if ((n+1)%6==0 || (n-1)%6==0) { if (n/5 < 1 && n%5!=0) {
is_all_condition_true=true; cout<< n << " is not a prime number"<< endl; } } }
if (is_all_condition_true)
cout<< n <<" is a prime number" << endl;
I hope this will help you and the algorithm works nicely as far as I saw.
Similar questions