Advertisement
Guest User

Calculadora primos

a guest
Jul 26th, 2015
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int num, divisor = 3;
  6.  
  7. bool esPrimo( int num, int divisor );
  8.  
  9. int main()
  10. {
  11. esPrimo(num)
  12. }
  13.  
  14. bool esPrimo ( int num, int divisor ){
  15.     if ( num != 2 and num % 2 == 0 ){
  16.         return false;
  17.     }
  18.     else if ( divisor != num and divisor != 1 and num % divisor == 0 ){
  19.         return false;
  20.     }
  21.     else esPrimo ( num, ++divisor );
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement