Function to convert each number in a M..N to another number in the same range

I'm trying to find a function that can convert each number (I mean natural numbers) in the range M..N to another number in the same range. Later I need to convert it back.

Let's take the 0..99 range for example. A very easy solution is:

b = 99 - a later to find a from b: a = 99 - b. And we can be sure that a and b will be in the 0..99 range.

What I want is the following If I convert all numbers from the linear series 0,1,2,3,4..99 with the function above I get 99, 98, 97, 96, 95..0, which is another linear one.

I would like to convert 0..99 to a non-linear series, but remaining in the same range.

Something like: 0 -> 11; 1 -> 52; 2 -> 77; etc. and later convert these numbers back.

Is there a mathematical function that can do this?

EDIT The function can be also an algorithm containing conditions, loops, etc. I will implement this in a programming language.

-
Permutation – M. Strochyk Dec 16 '12 at 10:49
Can you be more specific please? – Tamás Pap Dec 16 '12 at 10:51

A good function for this is the modulo operator.

$$f(n)=an\bmod{100}$$

The choice of $a$ is up to you, but if $\gcd(a,100)=1$, then the mapping will be bijective, and the inverse function is

$$f^{-1}(n)=bn\bmod{100},$$

where $b$ is the unique integer such that $ab\equiv1\pmod{100}$. (This number can be found using the Euclidean algorithm.)

-
I really like this idea. Thank you! – Tamás Pap Dec 16 '12 at 11:48

Write thenumbers $0,\ldots,99$ on cards, shuffle them and write down there new order. E.g. if the first three cards read $11, 52, 77$ let your first function map $0\mapsto 11$, $1\mapsto 52$, $2\mapsto 77$ and so on. At the same time note the inverse function by writing a second table where in each row you note at which place in the seqeunce a number occured. Thus after the first three cards you will have noted $11\mapsto 0$, $52\mapsto 1$, $77\mapsto 2$.

These two arrays define functiuons that are inverse of each other as required.

-
Thank you for your answer Hagen! This is a possible solution I can implement. – Tamás Pap Dec 16 '12 at 11:48