Skip to content

Instantly share code, notes, and snippets.

@alvareztech
Created March 22, 2016 03:06
Show Gist options
  • Select an option

  • Save alvareztech/7a8144e98830b208e02e to your computer and use it in GitHub Desktop.

Select an option

Save alvareztech/7a8144e98830b208e02e to your computer and use it in GitHub Desktop.
Tower of Hanoi recursive algorithm
public static void algoritmoHanoi(int n, int origen, int temporal, int destino) {
if (n == 0) {
return;
}
algoritmoHanoi(n - 1, origen, destino, temporal);
System.out.println("Mover " + n + " de la torre " + origen + " a la torre " + destino + ".");
algoritmoHanoi(n - 1, temporal, origen, destino);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment