- factorial, Mathematical

Exponential factorial of N

Exponential factorial of N Given a positive integer N, the task is to print the Exponential factorial of N. Since the output can be very large, print the answer modulus 1000000007. Examples:  Input: N = 4  Output: 262144   Input: N = 3  Output: 9  Approach: The given problem can be solved based on the following observations: The exponential factorial is defined by the recurrence relation: .Follow the steps below to solve the problem:Initialize a variable say res as 1 to store the exponential factorial of N.Iterate over the range [2, N] using the variable i and in each iteration update the res as res = ires%1000000007.Finally, after completing the above step, print the answer obtained in res.Below is the implementation of the above approach:C++#include using namespace std;int ExpoFactorial(int N){           int res = 1;    int mod = 1000000007;        for (int i = 2; i < N + 1; i++)                       res = (int)pow(i, res) % mod;        return res;}int main(){        int N = 4;           cout