Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- int a;
- int suma(1);
- cout<<"Unesite prirodan broj: ";
- while(cin>>a, a!=0) {
- if (!std::cin) cout<<"Niste unijeli broj!";
- else if (a<=0) cout<<"Niste unijeli prirodan broj!";
- else {
- for (int i=2; i<=a; i++)
- {
- if (a%i==0)
- {
- suma+=i;
- }
- } cout<<"Suma svih djelilaca broja "<<a<<" iznosi:"<<suma<<endl; }
- cout<<"Unesite novi broj: ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement