# Thread: Finding divisors

1. Originally Posted by xbusterx
um like sum += num ?
Right.

2. Originally Posted by tabstop
Right.
Ya don't I don't know how to do that here since i is changing.

3. Originally Posted by xbusterx
Ya don't I don't know how to do that here since i is changing.
Since that's exactly what you want and need to happen, I fail to see how that's a problem.

(Or is your task not to add, but to count? In that case you would always add 1, since that's how people count.)

4. Originally Posted by tabstop
Since that's exactly what you want and need to happen, I fail to see how that's a problem.

(Or is your task not to add, but to count? In that case you would always add 1, since that's how people count.)

Ok so can I do this?

Code:
```int sum =0;
int n;

cout << enter number;
cin >> n;

for (int i = 1 ; i < n ; i++ )

if ( n &#37; i = 0 )
sum += i```

5. You have to use == to compare numbers, but yes, that's what we've been waiting for.

6. Originally Posted by tabstop
You have to use == to compare numbers, but yes, that's what we've been waiting for.
Code:
```int sum =0;
int n;

cout << enter number;
cin >> n;

for (int i = 1 ; i < n ; i++ )

if ( n % i == 0 )
sum += i```

better lol?

Popular pages Recent additions