Towers of Hanoi: Difference between revisions

Line 407:
250 SP = SP - 1 : REM RESTORE STACK POINTER FOR CALLER
260 RETURN</lang>
 
===Using binary method===
{{works with|Commodore BASIC}}
Very fast version in BASIC V2 on Commodore C-64
<lang gwbasic> 10 def fnm(x)=x-int(x/3)*3:rem modulo
20 n=4
30 gosub 100
40 end
100 rem hanoi
110 for m=1 to 2^n-1
120 :print m;":",fnm(m and m-1)+1;" to ";fnm((m or m-1)+1)+1
130 next
140 return</lang>
 
=={{header|BASIC256}}==