I'm trying to make a system of diminishing returns by using a logarithmic algorithm, but I don't know how to make that in Lua. I have come up with this...

local startNumber = a
local goalNumber = b
local outcome = 1

while startNumber < goalNumber do
	outcome = outcome + 1
	startNumber = startNumber * a
end

print(outcome)

but obviously, this code has some flaws.

log2(1) would give 1 when it's supposed to give 0,

local2(10) would give 4 when it's supposed to give something around 3.32,

and the faulty outcome continues...

Any ideas of how mo make it accurate no matter what I put in?