Question: I am stuck Recursion practice Recall from our discussion last week how recursion works Let's take the factorial example We have either a base case

 I am stuck Recursion practice Recall from our discussion last week

I am stuck

Recursion practice Recall from our discussion last week how recursion works Let's take the factorial example We have either a base case (a terminating condition) or a recursive step In the factorial example nl=n*(n-1)! O! = 1 6! = 6x5! = 6x5x4! =6x5x4x3x2x1x0! = 720 We are going to build a function that calculates the multiplicate persistence of a number. The term is scary, but all it means is we multiply all the digits in a number together, and we repeat until we get a single digit. Here is an example mult_per(1234) = 1x2x3x4 = 24 24 is not a single digit, do it again! 2x4 = 8 8 is a single digit, stop here You must solve this using recursion! In [97]: def mult_per(number): if number == 1: return 1 else: ph = number * mult_per(number-1) test = number return ph In [98]: number = 4 print(mult_per(number)) 24

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!