title: Create a random permutation of 1..N in constant space
body: <p>I am looking to enumerate a random permutation of the numbers 1..N in fixed space. This means that I cannot store all numbers in a list. The reason for that is that N can be very large, more than available memory. I still want to be able to walk through such a permutation of numbers one at a time, visiting each number exactly once.</p>
  
  <p>I know this can be done for certain N: Many random number generators cycle through their whole state space randomly, but entirely. A good random number generator with state size of 32 bit will emit a permutation of the numbers 0..(2^32)-1. Every number exactly once.</p>
  
  <p>I want to get to pick N to be any number at all and not be constrained to powers of 2 for example. Is there an algorithm for this?</p>