I want to find out a function or algorithm, whichever is suitable, which can provide me a random sequence. Like
Input: 3
Output: {1,2,3} or {1,3,2} or {2,1,3} or {2,3,1} or {3,1,3} or {3,2,1}
Same as if I will enter a number N, output will be a random permutation of the set {1,2,...N}
How can a I write this type of algorithm. Actually I want to find out the logic behind it.
Edit: I don't want to use any buffer to to save anything.