mirror of
https://github.com/CPunch/Cosmo.git
synced 2025-11-10 09:30:06 +00:00
replaced facttest.lua with fibtest.lua
Optimized the NaN box to be byte aligned, performance under the fibtest.lua script improved by ~2.5 seconds (~31 before ~28.5 after on cpunch's machine) also cleaned up some misc. comments
This commit is contained in:
11
examples/fibtest.lua
Normal file
11
examples/fibtest.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
local function fib(num)
|
||||
if num <= 1 then
|
||||
return num
|
||||
else
|
||||
return fib(num-2) + fib(num-1)
|
||||
end
|
||||
end
|
||||
|
||||
for (var i = 1; i < 40; i++) do
|
||||
print("The fib number of " .. i .. " is " .. fib(i))
|
||||
end
|
||||
@@ -1,13 +0,0 @@
|
||||
local function fact(num)
|
||||
var total = 1
|
||||
for (var i = num; i > 0; i = i - 1) do
|
||||
total = total * i
|
||||
end
|
||||
return total
|
||||
end
|
||||
|
||||
for (var x = 0; x < 1000; x=x+1) do
|
||||
for (var z = 0; z < 100; z=z+1) do
|
||||
print("The factorial of " .. x .. "." .. z .. " is " .. fact(z))
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user