You
need to calculate numbers until any repetition occurs. For
preventing the time limit I use an array whose index is the
number and element is the order by which it comes. For example,
array[] is that array. Z = 5, L = 5, M = 12 and Seed is 4. Then,