Advertisement
STANAANDREY

_2nrprmmici

Nov 13th, 2018
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main () {
  6.  
  7.     int n,nr=0,i=2,eprim;
  8.     cin>>n;
  9.  
  10.     while (nr!=2){
  11.         eprim=1;
  12.         n--;
  13.  
  14.         while (i<=n/2&&eprim==1)
  15.             {
  16.                 if (n%i==0)
  17.             eprim=0;
  18.         i++;
  19.         }
  20.         if (eprim==1) {
  21.         cout<<n<<" ";
  22.         nr++;
  23.         }
  24.  
  25.         i=2;}
  26.  
  27.  
  28.   return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement