First, I need to write a function to print out all the factors of a number, and I did it.
Then, I need to write one more function to add up all the numbers in that function. I am stuck though, I came up something, but it wont work, or how can i utilize the first function into my second one? Thanks
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
void printdivisors(int x) {
for (int i = 1; i < x; i++) {
if (x % i == 0)
cout << i << endl;
}
}
void sumdivisors(int x) {
int sum;
for (int i = 1; i < x; i++) {
if (x % i == 0)
cout << i << endl;
i = x;
sum = i + x;
}
}