title: How can I write a power function myself?
body: <p>I was always wondering how I can make a function which calculates the power (e.g. 2<sup>3</sup>) myself. In most languages these are included in the standard library, mostly as <code>pow(double x, double y)</code>, but how can I write it myself?</p>
  
  <p>I was thinking about <code>for loops</code>, but it think my brain got in a loop (when I wanted to do a power with a non-integer exponent, like 5<sup>4.5</sup> or negatives 2<sup>-21</sup>) and I went crazy ;)</p>
  
  <p>So, how can I write a function which calculates the power of a real number? Thanks</p>
  
  <hr>
  
  <p>Oh, maybe important to note: I cannot use functions which use powers (e.g. <code>exp</code>), which would make this ultimately useless.</p>