Derangements Small

Derangements Small

Hard Computer Mathematics Combinatorics 33 views
Explanation Complexity

Problem Statement

Compute number of derangements for n

Input Format

One integer n.

Output Format

One integer.

Example

4
9

Constraints

0

Input / Output Format

Input Format
One integer n.
Output Format
One integer.
Constraints
0

Examples

Input:
4
Output:
9

Example Solution (Public)

Computer Mathematics
Use recurrence D(0)=1,D(1)=0,D(n)=(n-1)*(D(n-1)+D(n-2)).

Official Solution Code

Use recurrence D(0)=1,D(1)=0,D(n)=(n-1)*(D(n-1)+D(n-2)).
Please login to submit solutions.
Editor
Output

                                        
Please login to submit solutions.