Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/wapython
Path: blob/main/core/lua/src/sum.lua
1067 views
1
2
-- sum the integers from 1 up to n
3
function sum (n)
4
local s = 0
5
for i = 1,n do
6
s = s + i
7
end
8
return s
9
end
10
11
start = os.clock()
12
s = sum(10000000)
13
print(s, os.clock()-start)
14