If you do print(|-3|) would it print 3? I tried this once and it didn't work, but I still think there is a way to find absolute value. I want it to be simple and not like:
local number = {-4, 4, 5, -98}
for _, num in pairs(number) do
if num > 0 then
num = num*-1
print(num)
else
print(num)
end
I also want to know if you can do factorial in lua: print(3!) should print 6, unless I've done it wrong(that would be embarrassing.) This is how you could do it but it's too long.
local number = {3, 5, 7}
for _,num in pairs(number) do
if num == 0 then
print(1)
elseif num < 0 then
repeat
bleh = -1
num = num*num+bleh
bleh = bleh-1
until num-bleh = 1
print(num)
elseif num > 0 then
repeat
bleh = 1
num = num*num-bleh
bleh = bleh+1
until num+bleh = -1
print(num)
end
end
end
Thanks in advance! BTW: I know these scripts don't work, I made them in under a min. Expect bugs and me spelling things wrong.

1 comment
Wow, this is a legit question, if you don't know math, that's no excuse for thumbing down.