Polnochniy

Untitled

Nov 6th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 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. if (n > 1)
  8. {
  9. for (w = 2; w < n; w++)
  10. if (n % w == 0)
  11. return false;
  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