fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int divizor = 2;
  8. int este_prim = 1;
  9. while (divizor < n) {
  10. if (n % divizor == 0) {
  11. este_prim = 0;
  12. }
  13. ++divizor;
  14. }
  15. if (n == 1) {
  16. este_prim = 0;
  17. }
  18. if (este_prim == 1) {
  19. cout << "este prim";
  20. }else{
  21. cout << "nu este prim";
  22. }
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0.01s 5320KB
stdin
6
stdout
nu este prim