Shrink calpi function

master
Benrob0329 2021-02-09 04:41:48 +00:00
parent b958af6424
commit a95743b0e1
1 changed files with 8 additions and 11 deletions

View File

@ -1,19 +1,16 @@
local calpi = function()
local operator = '+'
local unpack = unpack or table.unpack
local function calpi()
local op = true
local operator = "+"
local mypi = 0
for i=1, 10000000000, 2 do
if operator == '+' then
mypi = mypi + (4/i)
operator = '-'
elseif operator == '-' then
mypi = mypi - (4/i)
operator = '+'
end
mypi, op = (op and mypi+(4/i) or mypi-(4/i)), (not op and true or false)
end
end
start = os.clock()
calpi()
print(calpi())
stop = os.clock()
return (stop - start)
print (stop - start)