title: Translating recursive method into an iterative method
body: <p>I want to change this recursive method into an iterative method using a while and or for loop but am having trouble. Here is the Recursive method I want to translate:</p>
  <pre><code>public static int recursiveNum (int n)
     {
        if(n&lt;=2)
        {  
            return 1;     
        }
        else
        {       
           return recursiveNum(n-1)+recursiveNum(n-2);
        }
     }
  </code></pre>
  <p>What i've attempted so far:</p>
  <pre><code>public static int iterativeNum (int n) { 
        while (i&lt;n) {
           i++;
           if (n&lt;=2) {
              return 1; 
              }
          
           else {
              return n = (n-1) + (n-2);
              }
           }
           return n;
        }
  </code></pre>