human
Count Derangements ( Permutation such that no element appears in its original position ) | Function to count derangements.
Create an array to store counts for subproblems.
Base cases.
Fill der [ 0. . n ] in bottom up manner using above recursive formula.
Return result for n.
Driver Code"
Solution in Python:

Give me a code to count Derangements ( Permutation such that no element appears in its original position ) and the other steps required?
assistant
#Here is code to count Derangements ( Permutation such that no element appears in its original position ) and the other steps required.
 def countDer ( n ) :
	der = [ 0 for i in range ( n + 1 ) ]
	der [ 1 ] = 0
	der [ 2 ] = 1
	for i in range ( 3 , n + 1 ) :
		der [ i ] = ( i - 1 ) * ( der [ i - 1 ] + der [ i - 2 ] )
	return der [ n ]
n = 4
print ( " Count ▁ of ▁ Derangements ▁ is ▁ " , countDer ( n ) )