Count of factors in loop

Hello all. I have this program where i am trying to figure out the factors of a given number through another file. But what i am having trouble with is adding up the number of factors that the number actually has. I have this so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  int main()
{

  int poss_digits, num_factors, num_primes, num_composites, num_neither;
  int num = 0;
  int factor = 0;
  int count = 0;
  int sum = 0;

  while(cin >> poss_digits)
    {

      if (poss_digits > 0)
        {
          for(int i = 1; i <= num ; i++)
            {
              if(num % i == 0)
                {

                  factor++;
                  sum = sum+i;
                  count++;
                  cout << sum;
                }
            }
        }

   return 0;
}

Last edited on
What exactly is the problem?
Topic archived. No new replies allowed.