Advertisement
Donald_Fortier

isPrime function that returns 4 as a prime

May 21st, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. bool isPrime( int num ) {
  2.     bool prime = true;// Assume it is a prime
  3.  
  4.     for ( int divisor = 2; divisor < num / 2; divisor++ )
  5.         if ( num % divisor == 0 )
  6.             prime = false;// Not a prime since it's dividable by something.
  7.  
  8.     return prime;// Return the result
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement