📅  最后修改于: 2022-03-11 14:54:54.808000             🧑  作者: Mango
function math.average(t)
local sum = 0
for _,v in pairs(t) do -- Get the sum of all numbers in t
sum = sum + v
end
return sum / #t
end
print(math.average({9, 10, 12, 13, 13, 13, 15, 15, 16, 16, 18, 22, 23, 24, 24, 25})) -- Result: 16.75