function move(n, a, b, k) { document.form.textarea.value += ("move "+n+" from "+a+" to "+b+"\n"); } function hanoi(n, a, b, c, k) { if (n>0) { hanoi(n-1, a, c, b); move(n, a, b); hanoi(n-1, c, b, a); } } function exec() { hanoi(5, 'a', 'b', 'c'); }