Advertisement
Polnochniy

Untitled

Nov 6th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. bool isPrime(int N)
  4. {
  5. int w, n;
  6. n = N;
  7. for (w = 2; w < n - 1; w++)
  8. if (n % w == 0)
  9. {
  10. return false;
  11. }
  12.  
  13. return true;
  14.  
  15. return false;
  16. }
  17.  
  18. int main()
  19. {
  20. setlocale(LC_ALL, "Rus");
  21. cout << "Введите число. Является ли оно простым ? "<< endl;
  22. int N;
  23. cin >> N;
  24.  
  25. if (isPrime(N) == true)
  26. cout << "Число простое" << endl;
  27. else
  28. cout << "Число не простое" << endl;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement