Please provide explanation with your answers. Simply posting code does not spread knowledge of integral scripting processes which helps people understand the logic and reasoning behind your answer.
06 | if math.floor(mid) = = mid then |
09 | median = (nums [ math.floor(mid) ] +nums [ math.ceil(mid) ] )/ 2 |
17 | for _,v in pairs (nums) do |
Call them like so:
1 | print (Mean( 5 , 10 , 20 , 2 , 1 , 4 )) |
2 | print (Median( 5 , 10 , 20 , 2 , 1 , 4 )) |
If you would prefer to use tables, change the '...' parameters to 'nums' and remove the lines that say local nums = {...}