title: Recursive power function: approach
body: <p>I'm programming for a while now(beginner), and recursive functions are a somewhat abstract concept for me. I would not say I'm stuck, program works fine, I'm just wondering if the function itself could be written without the pow function in the code (but still doing exactly what the problem suggests)</p>
  
  <p>Problem:
  <a href="http://prntscr.com/30hxg9" rel="nofollow">http://prntscr.com/30hxg9</a></p>
  
  <p>My solution:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;math.h&gt;
  
  int power(int, int);
  
  int main(void)
  {
      int x, n;
      printf("Enter a number and power you wish to raise it to: ");
      scanf_s("%d %d", &amp;x, &amp;n);
      printf("Result: %d\n", power(n, x));
      return 0;
  }
  
  int power(int x, int n)
  {
      if (n == 0) return 1;
      if (n % 2 == 0) return pow(power(x, n / 2), 2);
      else return x * power(x, n - 1);
  }
  </code></pre>
  
  <p>I've tried doing this: power(power(x, n - 1), 2);
  but execution failed, and I'm still backtracking why.</p>