@c+
module test15 -- hanoiTowers
 -- test of simple recursion with local variables
private
 integer From, To, Using, count;
 proc hanoi() 
        integer holdCount, F,T,U;
        begin
		 holdCount:= count;
		 F := From;
		 T := To;
		 U := Using;
		 if	holdCount = 0 -> skip;	 	
		 []	holdCount > 0 -> 
					count := holdCount -1;
					From := F;
					To	:= U;
					Using := T;
					hanoi();	--first	recursion
					write 'move from ',F,'	to ',T ;
					count := holdCount-1;
					From := U;
					To	:= T;
					Using := F;
					hanoi();	--second recursion
        fi;
        return;
        end;
	

 begin
read count; -- use a small value -- say 4
From := 1;
To := 2;
Using := 3;
hanoi();
end.
