Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getAverage(table)
- local h
- local r
- h = 0
- for i=1, #table do
- r = tonumber(table[i])
- if r == nil then
- error("Table had non-numerical index")
- return nil
- end
- h = h + r
- end
- h = h / #table
- return h
- end
- function getFactors(num)
- local factors = {}
- local lol = tonumber(num)
- if lol == nil then
- error("Number expected: got "..type(num))
- return false
- end
- num = lol
- for i=1, num do
- if num % i == 0 then
- table.insert(factors, i)
- end
- end
- return factors
- end
Advertisement
Add Comment
Please, Sign In to add comment