Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //E gresita, nu merge.
- #include <iostream>
- using namespace std;
- int main()
- {
- int x,n,cx,numar,S=0,OK=1,i;
- cout<<"n="<<endl;
- cin>>n;
- for (x=n;x>1;x=x-1)
- {
- cx=x;
- numar=x;
- while(cx)
- {
- S=S + (cx%10);
- cx=cx/10;
- }
- for (i=2;i<=S-1;i++)
- {
- if (S%i==0)
- OK=0;
- }
- if (OK==1)
- cout<<numar<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement