In: Computer Science
Given is a sequence of the following pattern: {1, 2, 6, 24, 120, 720, …}
1. Write recursive equations for the above sequence.
2. Write a C++ recursive function that can compute the sequence
in 1. above of any
unsigned long number.
The n-th term of the sequence is the product of the first n positive integers.
1. The following recursive function f returns the n-th term of the above sequence:
2. The following function can be used in C++:
unsigned long int f(unsigned long int n)
{
if(n > 1)
return n * f(n - 1);
else
return 1;
}
The following is the whole program:
The following is a trial output of the code: