Invertible function that "messes" order I am looking for an invertible discrete function $f$ such that given some integer n, if i apply $f(i)$ for $i=0,\dots,n$ I would get all the integers in range $[0..n)$ exactly once, but in a "messy" - "random" if you will manner. 
I thought about finding a generator for the group $(\Bbb Z_n,\cdot)$, but im not sure if it would work for any given $n\dots$ (would it?)
any other ideas?
 A: I think what you are talking about is defining $f(i) := x^i$ for $i>0$ and $f(0) = 0$ where $x$ is a generator of the multiplicative group of integers mod $n$ -- called a primitive root. To avoid the predictability of the $f(0)$, you could define $f(0) = a$ and $f(i) = x^i + a$ (mod $n$).This is a good idea, as usually it will give that random-seeming arrangement, but it requires the group in question be cyclic, which is only true if $n =$ 1, 2, 4, $p^k$, or $2p^k$ for prime $p$.
A: In order to extend Quinn's answer to more general $n$:
Suppose you can write $n=ab$ with $\gcd(a,b)=1$ and you have a "nice" random permutation function $f_a$ modulo $a$, but not modulo $b$. Then we can simple pick a "bad" random permutation function  $f_b(i)=i\bmod b$ and combine those to 
$$f_n(i)=j\bmod n$$
where
$$j\equiv f_a(i\bmod a)\pmod a\quad\text{ and }\quad  j\equiv f_b(i\bmod b)\pmod b $$
Of course we'd expect things to be "even messier" if $f_b$ is also a nice random permutation. In the light of Quinn's answer, we should be in good shape as long as $n$ is not a power of $2$. (Though the permutation the above method produces in extreme cases such as $3\cdot 2^k$) might not be very random). 
Some specific method for powers of $2$ should be used. I suggest multiplication $\bmod 2^k$ with an odd factor $u\approx \phi2^k$ where $\phi$ is the golden ratio.
