Move n disks from peg A to peg C, using B, never placing a larger disk on a smaller one. The recursive idea: move n − 1 disks out of the way (A → B), move the largest disk (A → C), move the n − 1 disks back on top (B → C).
Write Hanoi with solve(int n, char from, char to, char via) that counts moves in a static field and prints the first limit moves (1. disk 1 A -> C), and long countMoves(int n) computed recursively from M(n) = 2·M(n − 1) + 1. main reads n and limit and prints:
1. disk 1 A -> C
2. disk 2 A -> B
3. disk 1 C -> B
... (4 more moves)
Total moves: 7, formula: 7
63 disks: 9223372036854775807 moves = Long.MAX_VALUE? true