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
Code Example |
---|
Lua :: lua round number |
Lua :: roblox make kill brick |
Lua :: roblox index and newindex |
Lua :: lua string to number |
Lua :: luau how to loop through all players |
Lua :: roblox tween part color |
Lua :: lua drawinrect |
Lua :: luau table.find |
Lua :: roblox vector3 |
Lua :: lua gsub |
Lua :: how to get the player mouse in roblox studio |
Lua :: lua json decode |
Lua :: change material roblox lua |
Lua :: roblox camera manipulation |
Lua :: hello world in lua |
Lua :: roblox touch part kill script |
Lua :: svelte template vite |
Lua :: unsur unsur hidrogen |
Lua :: swap number in lua |
Lua :: roblox can I have player animations on the server |
Matlab :: anonymous function matlab |
Matlab :: matlab single and double |
Matlab :: SAVE TABLE IN MATLAB |
Basic :: Trollbox |
Elixir :: elixir try rescue |
Elixir :: elixir check memory usage |
Scala :: scala string to lower case |
Scala :: scala schema json spark |
Excel :: excel formula update insert row column |
Perl :: perl while loop |