Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1.  
  2. #include "stdafx.h"
  3. #include <iostream>
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     int n1, n2,p1;
  10.    
  11.     cout << "unesi raspon od do " << endl;
  12.     cin >> n1;
  13.     cin >> n2;
  14.     if (n1 > n2)
  15.     {
  16.         n3 = n1;
  17.         n1 = n2;
  18.         n2 = n3;
  19.     }
  20.    
  21.  
  22.         for (int j = n1; j <= n2; j++)
  23.         {
  24.             if (j == 1)
  25.             {
  26.                 p1 = 1;
  27.             }
  28.             else if(j==2)
  29.             {
  30.                 p1 = 2;
  31.             }
  32.             else
  33.             {
  34.                 for (int i = 2; i < j; i++)
  35.                 {
  36.  
  37.                     if (j%i != 0)
  38.                     {
  39.                         p1 = j;
  40.                     }
  41.                     else
  42.                     {
  43.                        
  44.                         break;
  45.                     }
  46.                 }
  47.             }
  48. cout<<p1<<endl;
  49.   return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement