import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String src = “T1”;
String dest = “T2”;
String helper = “T3”;
toh(n, src, dest, helper);
}
public static void toh(int n, String src, String dest, String helper)
{
//base case
if(n==0)
{
return;
}
toh(n-1, src, helper, dest);
System.out.println("move "+n+"th disc from "+src+ " to " +dest);
toh(n-1, helper,dest,src);
}
}
how to display steps?
