This is a well-known problem: a permutation of the numbers from 1..n which does not leave any element fixed is a 'derangement' and you can find a Wikipedia article at http://en.wikipedia.org/wiki/Derangement and a Mathworld article at http://mathworld.wolfram.com/Derangement.html