JSFiddle - React, Tailwind, and code Playground

by skwjdgn

JavaScript

//const n = Math.round(Math.random()*100);


let hanoi = (n, s, t, e) => {
		
		if( n === 1){
    		console.log(n+":"+s + "->" + e)
    }else{
     		hanoi(n-1, s, e, t);
       	console.log(n+":"+s + "->" + e)
        hanoi(n-1, t, s, e);
    }
   
}

let s = 1;
let t = 2;
let e = 3;

hanoi(5, s, t, e);