Have you tried to calculate the number of mobile steps in Hanno? Is there no result for a few days a few days, and it is still crafted ... I now find a mobile law that is now shared with you.
When Hannota moves, three trays have to move 7 steps, which is fixed. When four trays, it will move the top three trays to another needle (this moved 7 steps), then move the fourth tray to another (at this time 8 steps, the 7 steps of the three plates plus the fourth plate 1 step), and finally move the three trays to the fourth plate (another 7 step), so four trays should be moved 15 step. The five plates are also the same, we know that the number of mobile steps in four trays is 15 steps, then 5 plates are 15 1 15 equal to 31. This concluded that each additional plate is added, its number of mobile steps increases a double plus 1 plus 1. Such as: We already know that 5 plates move 31 steps, then 6 plates are 31 * 2 1 = 63 steps.
You can write a C program:
#include
Void main () {
Long Double J = 7; / * j is used to record the number of mobile steps of the disk, because at least three plates, to define the initial value of 7 * /
INT i; / * i is used to store the number of trays * /
Printf ("Please enter a number greater than or equal to 3, less than or equal to 64:");
Scanf ("% D", & i);
IF (i> 64 && i <3) {
Printf ("cannot be calculated");
Else {
FOR (x = 3; x
J = j * 2 1;} / * calculates the formula of the number of mobile steps * /
Printf ("% d), I, J), i, j);
Is this not simpler? The above programs can only be considered to the number of mobile steps for 53 plates due to the accuracy of the long Double data type.
The number of mobile steps from the above formula is: 18446744073709551615