Program that calculates average boxes count opened to achieve low chance item

I created this simple script that calculates the average of “Boxes” to open in any type of games involving a rarity system and earnable items to achieve a very low chance item (In this case I took "Toilet Tower Defense" game as an example with their godly item of drop chance of 0.01%)

local numerator = 0
local denominator = 1000

for i = 1,denominator,1 do -- Denominator also represents the number of people contributed
	
	for i = 1, 100000000, 1 do -- Represents the number of boxes to open
		
		local result = math.random(100,10000) / 100 -- Divided by 100 to get floating point numbers

		if result > 99.99 and result <= 100 then -- 0.01 chance
			warn("Number of boxes until godly: ".. i)
			numerator += i 
			break
		end
	end
end

warn("Average boxes to open to get a godly: ".. numerator/denominator)

Result:


I thought it’s pretty intersting to look at those numbers for people who are grinding such games and alter that code to match their desire