Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Write a recursive function to calculate double factorial a, n!, where n is in

ID: 3704538 • Letter: 1

Question

1. Write a recursive function to calculate double factorial a, n!, where n is input by users. Please check slides for definition of double factorial 2. Assume a set {x: x is an even integer that>-0 and -32. Print out the number of its subsets. Moreover, print out the number of subsets that contain {2, 10, 24 You should let your C++ program to do the actual calculation. NOTE: For Problem 2, it is an application of product rule. Sample output: options compilation execution Problem 1 Please input an integer n: 6 double factorial is 48 Please input an integer n: 7 double factorial is 105 Problem 2 The set contains: 0246 8 10 12 14 16 18 20 22 24 26 28 30 32 The number of subsets is:XXXX The number of subsets containing (2, 10, 24) is Xxxx

Explanation / Answer

#include <iostream>
using namespace std;

// USING one parameter
int doublefactorial(int n)
{
// base case: returning either 1/2
if(n<=2)
return n;
  
// else it comes here and calls with 2 less n  
return n*doublefactorial(n-2);
}

int main() {
int number;
cout << "Please input an integer n: ";
cin >> number;
cout << number << " double factorial is " << doublefactorial(number);
}

/*SAMPLE OUTPUT
Please input an integer n: 6
6 double factorial is 48

Please input an integer n: 7
7 double factorial is 105
*/