title: the sum of divisor (other than itself)
body: <p>Write a program that reads integer from the keyboard and, on the output, writes the sum of the divisors of n (other than itself).</p>
  
  <p>I've created a method that finds the sum of divisor. Using the while statement I can have up to 10 integers entered by the user until EOF. In the while statement I had sum = the output of sum_divisor and print out sum.</p>
  
  <p>If I enter 0 0 0 4 5 6 12 then the output should be 0 0 0 3 1 6 16.
  The output I get is  0 0 0 3 4 10 26. How can I make it so that it doesn't add the sum_divisor to the previous sum?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int sum_divisor(int x);
  
  int main()
  {
      int x;
      int sum;
      printf("Enter up to 10 positive integer ending with EOF:\n");
  
      while((scanf("%d",&amp;x)) != EOF){
          sum = sum_divisor(x);
          printf("%d ", sum);
      }
      return 0;
  }
  
  int sum_divisor(int x){
  
      int i;
      int sum;
  
      if(x&lt;= 0){
          sum = 0;
      }
      else{
          for(i=1;i&lt;x;++i)
              {
                  if(x%i==0)
                      sum += i;
              }
      }
      return sum;
  }
  </code></pre>