Lua 5.2 Source Code

-- Author: Hannes du Plooy 
-- Date: 20 Sep 2016       
-- Objective: To solve the towers of hanoi with number of discs provided in the arguments to calling the program 

function hanoi(source,dest,other,discs)
    if discs>0 then 
        hanoi(source,other,dest,discs-1)
        print("Move ",source," to ",dest)
        hanoi(other,dest,source,discs-1)
    end
end

if #arg < 1 then
    print("Please provide number of discs!")
else
    hanoi(0,2,1,tonumber(arg[1]))
end