Towers Of Hanoi
by rakhi5b4
JavaScript
function towersOfHanoi(count, source, auxillary, destination) {
if(count == 1) {
console.log(source+'--'+destination);
} else {
towersOfHanoi(count-1, source, destination, auxillary);
towersOfHanoi(1, source, auxillary, destination);
towersOfHanoi(count-1, auxillary, source, destination);
}
}
towersOfHanoi(2, 'A','B', 'C');