请输入您要查询的百科知识:

 

词条 Module:Sandbox/TheTruthCreator/Sample1
释义

local p={}

function p.toString(n)

local digits = {"0","1","2","3","4","5","6","7","8","9"}

local str = ""

while not (n == 0) do

local m = n % 10

str = digits[m + 1] .. str

n = (n - m) / 10

end

return str

end

function p.isPrime(num)

local prime = true

for i = 2 , (num - 1) , 1 do

if num%i == 0 then

prime = false

end

end

return prime

end

function p.test(frame)

local str = frame.args[1]

return str

end

function p.mersenne(frame)

local n = frame.args[1]

local str = ""

local m = 3

for i = 2 , n , 1 do

if p.isPrime(m) then

str = str .. p.toString(m)

if not (i == n) then

str = str .. " "

end

m = (m * 2) + 1

end

end

if str == "" then

str = "What the heck???"

end

return str

end

return p

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/11 20:36:14