Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Sounds like you want an algorithm which is guaranteed to produce a cycle from 0 to n-1 without any repeats. There are almost certainly a whole bunch of these depending on your requirements; <a href="http://en.wikipedia.org/wiki/Group_theory" rel="nofollow noreferrer">group theory</a> would be the most helpful branch of mathematics if you want to delve into the theory behind it.</p> <p>If you want fast and don't care about predictability/security/statistical patterns, an LCG is probably the simplest approach. The wikipedia page you linked to contains this (fairly simple) set of requirements:</p> <blockquote> <p>The period of a general LCG is at most m, and for some choices of a much less than that. The LCG will have a full period if and only if:</p> <ol> <li>c and m are relatively prime,</li> <li>a - 1 is divisible by all prime factors of m</li> <li>a - 1 is a multiple of 4 if m is a multiple of 4</li> </ol> </blockquote> <p>Alternatively, you could choose a period N >= n, where N is the smallest value that has convenient numerical properties, and just discard any values produced between n and N-1. For example, the lowest N = 2<sup>k</sup> - 1 >= n would let you use <a href="http://en.wikipedia.org/wiki/LFSR" rel="nofollow noreferrer">linear feedback shift registers</a> (LFSR). Or find your favorite cryptographic algorithm (RSA, AES, DES, whatever) and given a particular key, figure out the space N of numbers it permutes, and for each step apply encryption once.</p> <p>If n is small but you want the security to be high, that's probably the trickiest case, as any sequence S is likely to have a period N much higher than n, but is also nontrivial to derive a nonrepeating sequence of numbers with a shorter period than N. (e.g. if you could take the output of S mod n and guarantee nonrepeating sequence of numbers, that would give information about S that an attacker might use)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload