title: Memoization for generating permuatation
body: <p>Is there any way to have memoization technique of generation the permutation. For example
   for numbers 1234...</p>
  
  <p>For me the problem is that it is taking a lot of memory. Is there any way to in some moderate amount of memory</p>