Guest User

Untitled

a guest
Oct 17th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. bool isPrime(int num)
  2. {
  3. int i;
  4. bool ans;
  5. i=2;
  6. while(i < num)
  7. {
  8. if(num%i == 0)
  9. {
  10. ans = false;
  11. //cout<<"\nisPrime? false";
  12. break;
  13. }
  14. i++;
  15. }
  16. if(i == num)
  17. {
  18. //cout<<"\nisPrime? true";
  19. ans = true;
  20. }
  21. return ans;
  22. }
Add Comment
Please, Sign In to add comment