Algorithms and Data Structures - Recursive Function Factorial - IT Assignment Help

Download Solution Order New Solution
Assignment Task:

Question 1 

Task 2.1 demonstrates how to create a recursive function factorial(int n). Task 2.6 demonstrates how to perform Tail Optimization to the recursive function square(int n) and transform it to a tail recursive function. We can follow the example and apply Tail Optimization to change factorial(int n) to a tail recursive function. 

Write a C++ program which 

• Prompts user to input an integer n smaller than 10; 

Please enter an integer n less than 10: 

• Uses a Tail Recursive version of factorial(int n) to calculate factorial n; 

• Outputs (e.g. n= 7) before terminating the program:

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.