This is what I currently have.
function maths.fact(n)
if not n then warn("invalid input.") return end
local f = 1
for i = 1, n do
f *= i
end
print(f)
end
This is what I currently have.
function maths.fact(n)
if not n then warn("invalid input.") return end
local f = 1
for i = 1, n do
f *= i
end
print(f)
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
what do you mean by work with floats? do you want a factorial of a fractional number? you can check here. https://math.stackexchange.com/questions/454053/how-do-we-calculate-factorials-for-numbers-with-decimal-places
Factorials: 1 * 2 * 3 ... * n, this means that decimals can't be factorials. They do however exist as gamma functions which I haven't learned yet.. There are a bit of sources that can guide you, can I ask why you need it to work with floats?