Question: Using fortran write a code; The Towers of Hanoi is a mathematical puzzle whose solution illustrates recursion. There are three pegs which can hold stacks
Using fortran write a code; The Towers of Hanoi is a mathematical puzzle whose solution illustrates recursion. There are three pegs which can hold stacks of disks of different diameters. A larger disk may never be stacked on top of a smaller. Starting with n disks on one peg, they must be moved to another peg one at a time. For n number of disks, the smallest number of steps (hanoi) to move the stack can be defined as the following function. Download the provided Program2.f90 file, and modify it by writing a Fortran function (called ToH) to take an integer-number (n) argument and return hanoi.

hanoi(n) 1 if n = 1 2. hanoi(n 1) +1 if n > 1 Sua CO dit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
