常用的LUA片段

生成TS的办法

local t=ngx.now();
local n=os.date("%Y%m%d%H%M%S").."00"..string.sub(t,12,14);
n=n..string.rep("0",19-string.len(n));
ngx.say(n);

产生101至200的所有素数

function is_prime(n) 
            for x = 2, math.sqrt(n) do
                if (n % x) == 0 then return false end
            end
            return true
        end
    
        total = 0
        for x = 101, 200 do
            if is_prime(x) then 
                total = total + 1
                ngx.say(x)
            end
        end
        ngx.say("Total " .. total .. "primes")  

使用素数解决表示多个标签组合查询

http://blog.csdn.net/duck_genuine/article/details/7430642

求质数算法的N种境界

http://blog.csdn.net/autumn20080101/article/details/9491131