fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int suma_dzielnikow(int n) {
  5. int suma = 0;
  6. for (int i = 1; i <= n; i++)
  7. if (n % i == 0) suma += i;
  8. return suma;
  9. }
  10.  
  11. int main() {
  12. cout << suma_dzielnikow(7) << " " << suma_dzielnikow(16) << endl;
  13. return 0;
  14. }
  15.  
  16.  
  17.  
  18.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
8 31