title: How to create an int[] division method using recursion with dividend and divisor as parameters?
body: <p>This problem <strong>MUST</strong> be solved using a <strong>recursion</strong>.</p>
  
  <p>I tried to use the code after the <em>"else"</em> to find the quotient using an int temp that counts how many times it is possible to divide (temp = dividend - divisor).</p>
  
  <p>int r is supposed to be the quotient, but since division() is not an int but an array, I can't apply the recursion. I tried also to insert division() inside result[0], but same thing, the return is an array, not an int.</p>
  
  <p>The result is an array with 2 elements: the quotient and remainder of the division.</p>
  
  <p>I've been practicing recursion but I'm lost in this mix of recursion and arrays</p>
  
  <p>I can probably solve this with a for loop but as I said, MUST use a recursion.</p>
  
  <p>Only the code between else and return should be modified. If this is supposed to be easy, I don't see it.</p>
  
  <p>I've been searching for answers before but the ones I've found use int as return, not array.</p>
  
  <p>This is the code with my failed test (as you can see in Main, the test dividend is 13 and divisor is 3):</p>
  
  <pre><code>public class Main{
  
      /*
       * Returns an array with the quotient and remainder of the
       * integer division
       *
       * @param dividend a positive int
       * @param divisor a positive int
       */
      static int[] division(int dividend, int divisor){
  
          int result[] = {0, dividend};
  
          if ( dividend &lt; divisor ){
              return result;
          } else{
  
              ***int temp = dividend - divisor;
              int r = 1 + division(temp , divisor);*** 
  
              return result;
          }
  
      }
  
      public static void main(String[] args){
          int result[]=division(13,3);
          System.out.println("Quotient: "+ result[0]
                 + " Remainder: "+ result[1]);
      }
  }
  </code></pre>