MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / towerOfHanoi

Method towerOfHanoi

Towerofhanoi.java:3–13  ·  view source on GitHub ↗
(int n, char from_rod, char to_rod, char helper_rod)

Source from the content-addressed store, hash-verified

1package com.JournalDev;
2public class Main {
3 static void towerOfHanoi(int n, char from_rod, char to_rod, char helper_rod)
4 {
5 if (n == 1)
6 {
7 System.out.println("Take disk 1 from rod " + from_rod + " to rod " + to_rod);
8 return;
9 }
10 towerOfHanoi(n-1, from_rod, helper_rod, to_rod);
11 System.out.println("Take disk " + n + " from rod " + from_rod + " to rod " + to_rod);
12 towerOfHanoi(n-1, helper_rod, to_rod, from_rod);
13 }
14
15 public static void main(String args[])
16 {

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected