daily pastebin goal
55%
SHARE
TWEET

Prime

ugbugduggel Jan 16th, 2019 148 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int prime = 0;
  2. int ii = 0;
  3.  
  4. //Proto
  5.  
  6. bool isitprime(int);
  7.  
  8. void main() {
  9.     cin >> prime;
  10.     for (ii=2; prime >= ii; ii++) {
  11.         if (isitprime(ii) == true)
  12.             cout << ii << endl;
  13.     }
  14.     system("PAUSE");
  15. }
  16.  
  17. bool isitprime(int input) {
  18.     for (int i=2; i <= input-1 ; i++) {
  19.         if (input%i == 0) {
  20.             cout << "Berechnung Beendet bei : " << i << endl;
  21.             return 0;
  22.         }
  23.     }
  24.     return 1;
  25. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top