Question: write in c programming language . question 5.36 Fibonaco for its rets ing terms, a) Write a warruse function fibonacci(n) that calculatus 0, 1, 1,

Fibonaco for its rets ing terms, a) Write a warruse function fibonacci(n) that calculatus 0, 1, 1, 2, 3, 5, 8, 13, 21,... (n) that calculates the n" Fib begins with the terms and 1 and has the property preceding terms. a) Write a cand unsigned long long int for i number. Use unsigned int for the function's paramete her that can be printed on your system. type. b) Determine the largest Fibonacci number that com 5.36 (Towers of Hai Every budding computer scientist must grapple with problems, and the Towers of Hanoi (see Fig. 5.23) is one of the most famous of these it that in a temple in the Far East, priests are attempting to move a stack of disks from another. The initial stack had 64 disks threaded onto one peg and arranged from botte decreasing size. The priests are attempting to move the stack from this peg to a second the constraints that exactly one disk is moved at a time, and at no time may a larger dist above a smaller disk. A third peg is available for temporarily holding the disks. Supposedly will end when the priests complete their task, so there's little incentive for us to facilitate ith certain classic of these. Legend has ks from one peg to com bottom to top by a second peg under rger disk be placed pposedly the world to facilitate their et forts. Let's assume that the priests are attempting to move the disks from peg 1 to peg 3. We will develop an algorithm that will print the precise sequence of disk-to-disk peg transfers. If we were to approach this problem with conventional methods, we'd rapidly find oursely hopelessly knotted up in managing the disks. Instead, if we attack the problem with recursion in mind, it immediately becomes tractable. Moving n disks can be viewed in terms of moving only 11 - 1 disks (and hence the recursion) as follows: a) Move n - 1 disks from peg 1 to peg 2, using peg 3 as a temporary holding area. Untents are Exercises 209 Fig. 5.23 Towers of Hanoi for the case with four disks. b) Move the last disk (the largest) from peg 1 to peg 3. c) Move the - 1 disks from peg 2 to peg 3, using peg 1 as a temporary holding area. The process ends when the last task involves moving - 1 disk, i.e., the base case. This is accomplished by trivially moving the disk without the need for a temporary holding area. Write a program to solve the Towers of Hanoi problem. Use a recursive function with four parameters: a) The number of disks to be moved b) The peg on which these disks are initially threaded c) The peg to which this stack of disks is to be moved d) The peg to be used as a temporary holding area Your program should print the precise instructions it will take to move the disks from the starting peg to the destination peg. For example, to move a stack of three disks from peg 1 to peg 3. your program should print the following series of moves: 1-3 (This means move one disk from peg 1 to peg 3.) 1 3 1 3 21 2 +3 1 +3 137 Come of Hanoi: Iterative Solution) Any program that can be implemented recursively unidamblu more difficulry and consid
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
