fork download
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4.  
  5. int main ()
  6. {
  7. int zahl, teiler {2}, ergebnis=1;
  8. cout << " Geben Sie eine Zahl ein. " ;
  9. cin >> zahl ;
  10. while ( teiler <= zahl )
  11. {ergebnis -= zahl % teiler <1;
  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. }
  20.  
Success #stdin #stdout 0.01s 5508KB
stdin
1000003
stdout
 Geben Sie eine Zahl ein. 1000003 ist eine Primzahl.