Hello Lua_01
Version 5.1.4-37
Unsuited Newcomer
First, let's look at an introductory example:
-----------------------------------------------
-- file: '0525.lua' -- desc: one ex helpful_guys = { "----这是一个引导性的例子,从这里开始.----", "一月", "二月", "三月", "四月", "五月", "六月", "\n", "----第二段----", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "\n" } for _,e in ipairs(helpful_guys) do print(e) end
Runtime result:
Look familiar? hehe, go on:
-- defines a factorial function function fact (n) if n == 0 then return 1 else return n * fact(n-1) end end print("enter a number:") a = io.read("*number") -- read a number print(fact(a))
Runtime result:
>Exit code: 0
>lua -e "io.stdout:setvbuf 'no'" "0525.lua"
enter a number:
3
6
>Exit code: 0