fork(3) download
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7. int zahl, teiler {2}, ergebnis=0;
  8. cout << " Geben Sie eine Zahl ein. " ;
  9. cin >> zahl ;
  10. while ( teiler < zahl )
  11. { ergebnis += zahl % teiler==0 ;
  12. teiler++ ;
  13. }
  14. if ( ergebnis != 0 )
  15. { cout << zahl << " ist keine Primzahl. \n " ; }
  16. else
  17. { cout << zahl << " ist eine Primzahl. \n " ; }
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5296KB
stdin
42
stdout
 Geben Sie eine Zahl ein. 42 ist keine Primzahl.