Question: Recursion problem A Continued fraction is an expression which has the form of (see picture) Write a python function using recursion only Continued_f(n, i) consumes

Recursion problem
Recursion problem A Continued fraction is an expression which has the form
A Continued fraction is an expression which has the form of (see picture)
Write a python function using recursion only
Continued_f(n, i)
consumes a positive number n and i (a total number of iteration times ,which is a positive integer). The final answer should he formatted as a string and should end with a full stop (.) after the last value.
e.g
Continued_f(1.75, 2)=> [1; 1, .]
Continued_f(17/14, 5) => [1; 4, 1, 2, .]
To compute a continued fraction for n, we iterate through these steps:
1. If n is an integer, add it to the end of the string and return.
2. If n is not an integer, round n down to its nearest integer(floor function is useful). Subtract this integer from n, This value is then included in the final answer.
3. The previous steps are repeated with the reciprocal of this number. Stop when you've performed this a total of i number of times or until you hit an integer.
For example, n=17/14, i=5 we start with the first integer 1, subtract it from 17/14 to get 3/14, and take the reciprocal 14/3 and repeat the process. 14/3 has the integer part 4 and subtract 4 from 14/3 to get 2/3. Then take the reciprocal and get 3/2. 3/2 has the integer part 1 and subtract from 3/2 to get 1/2, take the reciprocal to get 2. This is an integer and hence we are done. The continued fraction is
[1; 4, 1, 2]
of (see picture) Write a python function using recursion only Continued_f(n, i)

A Continued fraction is an expression which has the form of 1 a + Q2 + a3 + an Write a python function using recursion only Continued fin, 0) consumes a positive number n and (a total number of iteration times which is a positive integer). The final anawer should ha formatted as a string and should end with a fult lop() after the last value Continued. (1.76, 21:11 Continued.1017/14,5) 1:41.2.1 To compute a continued froction for n, weiterate through these steps: 1. It is an integer, addit it to the end of the string and return 2. If n is not an integer, round n down to its nearest Integer (floor function is useful) Subtract this integer from This value is the included in the final answer 3. The provious steps are repeated with the reciprocal of this number. Stop when you've performed this a total of number of times or until you hit an integer. For example, w17/14, 1-5 we start with the first integer 1, subtract it from 17/14 to get 3/14, and take the reciprocol 14/3 and repeat the process. 1/3 has the integer part 4 and subtract from 14/3 to get 2/3. Then take the reciprocal and get 3/2, 3/2 has the integer port 1 and subtract from 3/2 to get 1/2 take the reciprocal to get 2. This is an integer and hence we are done. The continued traction is 11:4, 1,2 1 1 + a2 + 1 1 + + an

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!