title: Why does cycle increment and not print out just the number of cycles?
body: <p>Please I have my code below. I am trying to get 8, 3, 1, 8, 1, 1, 1, 1, 1, 1. For the cycles in the output of my code, when the user inputs 45 23 6 12 0 0 0 0 0 0. But for some reason it adds up the next number subtracted by 1. So I get 8, 10, 10, 17, 17, 17, 17, 17, 17, 17. I have tried to fix this but nothing I do seems to help. Can someone please help me point out the reason why this is happening?</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  
  int sum_divisors(int); //Function Prototype
  
  /*Just wanted to do an example to show you don't need
   *function prototypes if you write the function itself
   *before main.
   */
  int cycles(int x){
      static int count = 1;
      int j;
      if(x == sum_divisors(x)){
          printf("%d%13d Cycle(s) \n", x, count);
      }else{
          x = sum_divisors(x);
          count++;
          printf("%d, ",x);
          cycles(x);
      }
  }
  
  int main(void){ //Start of main
      int count = 0;
      int x, sum;
      int i = 0;
      int nums [9];
  
      puts("Please enter 10 integers. Fill up the rest with 0s. Please only type in numbers if not you might not get the output you want.");
  
      while(scanf("%d ", &amp;x) != EOF){
          if(x &gt; 100){
              puts("Wrong input");
              exit(1);
          }else{
              count++;
              nums[i] = x;
              ++i;
          }           
  
          if(i == 9){
              break;
          }
      }
  
      for(i=0; i&lt;count; i++){
          sum = sum_divisors(nums[i]);
          printf("%d, ", nums[i]);
          cycles(nums[i]);
      }
  
      puts("");
  
      return 0;
  } //end of main
  
  int sum_divisors(int n){
  
      int i;
      int sum = 0;
      int prime_ind = 0;
  
      if(n &lt;= 1){
          sum = 0;
          return sum;
      }
  
      for(i=2; i&lt;n; i++){
          if(n%i == 0){
              prime_ind = 1;
              break;
          }
      }
  
      if(prime_ind == 0){
          sum = 1;
      }else{
          for(i=1; i&lt;((n/2)+1); i++){
              if(n%i == 0){
                  sum += i;
              }
          }
      }
      return sum;
  }
  </code></pre>