Derangement of numbers

Given a number n. Construct an array of n numbers from 0 to n.
Example
if n=3
arr[n]=[1,2,3].
Find the number of arrangements in which no object occurs at its original position.
Answer=2
[3,1,2],[2,3,1]

It is called Derangement of n numbers.

you can easily find the formula using inclusion exclusion principal and it’s proof on web.

One of them !!

3 Likes

somebody edit question title as “Derangement of numbers :D”.

//