Advertisement
sellmmaahh

tut1-zad4

Jul 20th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4.  
  5. int main ()
  6. {
  7.     std::cout<<"Unesite prirodan broj: ";
  8.     int n;
  9.     while (std::cin>>n, n!=0) {
  10.     if (!std::cin) {
  11.         std::cout<<"Pogresan unos. Ponovite :";
  12.     }
  13.     else {
  14.               int suma(1);
  15.         for (int i=2; i<=n; i++) {
  16.  
  17.             if (n%i==0) suma+=i;
  18.         }
  19.         std::cout<<"Suma: "<<suma<<std::endl;
  20.         std::cout<<"Unesite novi broj: ";
  21.     }}
  22.     return 0; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement