Looping Random Number Generator I'm not even sure if this is even possible, but I think it's worth a shot.

The Challenge

Code/conceptualize a pseudo-random number generator that has the potential to produce results evenly spaced out with similar frequencies... with a twist. The random number generator has to 'loop' back after Foo iterations to its beginning state then produce the exact same results. Foo is a variable of all positive integers.

For example, if the iterations amount is 4 and the random numbers generated after 4 iterations are {93,5,80,13}, then the next 4 iterations will produce {93,5,80,13}, as will the next 4 after that and so on.

Limitations


Random numbers can't be pre-defined. For example, the algorithm can't simply iterate over {1,2,3,4,...int.MaxValue}, up to the iteration amount then go back to the first value.
Similar to Limitation 1, random numbers can't be cached so a set of numbers can't be generated, saved, then repeatedly returned.
Similar to Limitation 2, the random number generator can't be 'forced' back to a certain state. Beginning seed numbers and whatnot cannot be saved.
The RNG can't use the number of iterations its run.


In other words, the Generator has to arrive back at its beginning state solely through consecutive calculations.

Objective

Shortest code wins!
J

I think the simplest solution to this would be the slightly bendy

   p =: 0
   random =: 3 : '(p =: y | &gt;: p) } ?. y # 0'


That is used like this:

   random 5
0.329284
   random 5
0.335644
   random 5
0.985972
   random 5
0.0583756
   random 5
0.038363
   random 5
0.329284


This can be easily modified to provide integers, just change the 0 to whatever value you want as a maximum. Alternatively, one might write the following code:

   p =: 0
   random =: 4 : '(p =: y | &gt;: p) } ?. y # x'


Used like this: 

   10 random 5
8
   10 random 5
6
   10 random 5
5
   10 random 5
4
   10 random 5
6
   10 random 5
8


How this works


   This uses the J primitive ?.: the statically seeded random number generator; as opposed to ?: the dynamically seeded random number generator. This makes sure the outcome is always the same when run with the same arguments. p is just a simple array pointer here, that gets incremented with every run of the function, up to a maximum of y: the left argument. Every time this code is executed, a list of y random numbers is generated (to comply with the rules). Yes, I do realize this is very much on the edge of the phrasing of the question and that it is most likely against the spirit of the question.