title: How to create a recursive exponential program that stores previous values of x
body: <p>Say you wanted to create a recursive exponential program in Matlab with input <code>exponential(A,n)</code>, which should display the result <code>A^n</code>. Doing this recursively would mean you would have to work out the number of times to multiply A. However, is it possible to save values of previously worked out powers?</p>
  
  <p>eg. To work out x^10 the program might work out x^5 and x^2. If it saved the values for x^5 and x^2 then to work out x^20 you only need to know what x^10 is, as x^5 and x^2 are already saved.</p>
  
  <p>My question is, how would you go about writing the code to store these in an array of stored values, of dimensions <code>m x m x 20</code> where m is the size of the matrix <code>x</code>and 20 is the max value you want to store.</p>