title: Decimal to Binary conversion using recursion with while loop
body: <p>my binary conversion doesn't work after it recurs a second time, it seems to work only during the first time through.  The purpose of the is have a user input a number to convert to Hex, Octal, and brinary from a integer and keep on asking and converting until the user inputs 0.  Please help! </p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  long toBinary(int);
  
  int main(void) {
      int number = 0;
      long bnum;   
      int zero = 0;
  
      while(number != zero) {
          puts("\nPlease enter a number you would like to convert to");
          puts("\nHexadecimal, octal, and binary: ");
          scanf("%d", &amp;number);
  
          if(number != zero) {
              printf("\nThe Hexadecimal format is: %x", number);
              printf("\nThe Octal format is: %o", number);
              bnum = toBinary(number);
              printf("\nThe binary format is: %ld\n", bnum);
          }
          else {
              puts("\nI'm sorry you have to enter a number greater than 0.\n");
              puts("\nOr have enter an invalid entry.");
  
          }
      }
      return 0;
  }   
  
  long toBinary(int number) {
      static long bnum, remainder, factor = 1;
      int long two = 2;
      int ten = 10;
  
      if(number != 0) {
          remainder = number % two;
          bnum = bnum + remainder * factor;
          factor = factor * ten;
          toBinary(number / 2);
      }
      return bnum;
  }       
  </code></pre>