title: How to compute a power of a power using recursion?
body: <p>I've recently been looking into recursion and it's been very confusing. I'm trying to write a java program which uses recursion to generate the result of a base number to a power, which also has a height of how many exponents the base has. For example, a base of two with a power of 3 and a height of 3 will result:</p>
  
  <blockquote>
    <p>(((2^3)^3)^3)</p>
  </blockquote>
  
  <p>Here is my (very flawed) code:</p>
  
  <pre><code>    public static void main(String[] args) {
      System.out.println(exponentWithHeight(2, 2, 3));
  }
  
  public static int exponentWithHeight(int base, int power, int height) {
      if (power &lt; 0 || height &lt; 0) {
          throw new IllegalArgumentException("Check input values.");
      }
      if (power == 0) {
          return 1;
      } else {
          return (base * height * exponentWithHeight(base, power - 1, height - 1));
      }
  }
  </code></pre>
  
  <p>I'm really not sure how to go about getting my desired output; As I said this is really confusing and new to me. Can someone help explain how to go about doing this?</p>