Advertisement
sellmmaahh

zad4-tutorijal1

Mar 3rd, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a;
  7.      int suma(1);
  8.       cout<<"Unesite prirodan broj: ";
  9.      while(cin>>a, a!=0) {
  10.     if (!std::cin) cout<<"Niste unijeli broj!";
  11.     else if (a<=0) cout<<"Niste unijeli prirodan broj!";
  12.     else {
  13.         for (int i=2; i<=a; i++)
  14.         {
  15.             if (a%i==0)
  16.             {
  17.                 suma+=i;
  18.         }
  19.  
  20.     } cout<<"Suma svih djelilaca broja "<<a<<" iznosi:"<<suma<<endl; }
  21.     cout<<"Unesite novi broj: ";
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement