#C8313. Modified Factorial
Modified Factorial
Modified Factorial
Given a positive integer (n), compute the modified factorial defined as follows:
- For (n = 1), (MF(1) = 1).
- For (n = 2), (MF(2) = 2).
- For (n \ge 3), the function is defined by the recurrence
(MF(n) = n \times MF(n-1) + n \times MF(n-2)).
Your task is to calculate (MF(n)) for the given input using an efficient algorithm.
inputFormat
A single integer (n) (where (n \ge 1)) is provided via standard input.
outputFormat
Output the computed value of the modified factorial (MF(n)) to standard output.## sample
1
1