Advertisement
DMG

Prosti blizanci (S)

DMG
Apr 3rd, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. // dragutinmajranovic
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. bool prost(int n)
  6. {
  7.      for (int i=2; i<n; i++)
  8.      if (n%i==0)
  9.         return false;
  10.      return true;
  11. }
  12.  
  13. main()
  14. {
  15.       int n, s = 0;
  16.       cin >> n;
  17.      
  18.       for (int i=1; i<n; i++)
  19.       if (prost(i)==true && prost(i+2)==true)
  20.          { // cout << i << " " << i+2 << endl;
  21.            s++; i = i + 2; }
  22.          
  23.       cout << s << endl;
  24.      
  25.       system("PAUSE");
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement