Question: Write a recursive procedure to implement the following function hotpon ) :hotpo ( n ) = 7 1 = 1 hotpon / 2 ) n

Write a recursive procedure to implement the following function hotpon):hotpo(n)=71=1hotpon/2) n>1, n is even hotpo(3*n+1) n>1, I is oddIn words:1. The procedure takes a natural number n (n >=1) as input;2. If n is even, divide it by 2 to get n /2;3. If n is odd, multiply it by 3 and add 1 to obtain 3n +1.4. Repeat the process until the result is 1. The procedure stops and returns 1.For example, if the input value is 3, the procedure will have the following recursive calls:(hotpo 3)(hotpo 10)(hotpo 5)(hotpo 16)(hotpo 8)(hotpo 4)(hotpo 2)(hotpo 1)Q1. Give the complete Scheme procedure by selecting the correct lines of code. (define hotpo (lambda (n)

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 Programming Questions!