Advertisement
MusicFreak

Prost Broj 7<p<n

Nov 7th, 2012
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.43 KB | None | 0 0
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<cmath>
  4.  
  5. using namespace std;
  6.  
  7. bool prostBroj (int a)
  8. {
  9.     bool u = true;
  10.     for (int i = 2; i<=int(sqrt(a)); i++)
  11.        if (a % i == 0)
  12.            u = false;
  13.    return u;
  14. }
  15. int main()
  16. {
  17.    int n;
  18.    cin>>n;
  19.     for (int p=8;p<n;p++)
  20.    {
  21.        if (prostBroj(p)==true)
  22.    if (prostBroj(n-p)==true)
  23.    cout<<n-p<<endl;
  24.    }
  25.    system("pause");
  26.    return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement