Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int max, i=2, count=0;
  7.     cout << "Mennyi prímet keresünk?: "; cin >> max;
  8.  
  9.     do {
  10.         int temp_var = 0;
  11.         for(int k=i; k>1; --k)
  12.         {
  13.             if(i % k == 0) {
  14.                 temp_var++;
  15.             }
  16.         }
  17.         if(temp_var == 1)
  18.         {  
  19.             cout << " * A " << i << " prím ..." << endl;
  20.             count++;
  21.         }
  22.         i++;
  23.  
  24.    } while(count != max);
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement