Last active
December 30, 2017 20:51
-
-
Save badcc/42ffb4dc65eb13cc783bde5d07408753 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Easy use | |
local Price0 = 50 | |
local Sales0 = 10000 | |
local Visits0 = 50000 | |
local Price1 = 200 | |
local Sales1 = 9000 | |
local Visits1 = 70000 | |
-- Math :) | |
local p0,s0,p1,s1=Price0,Sales0,Price1,Sales1*(Visits0/Visits1) | |
local m=(s1-s0)/(p1-p0) | |
local function f(p) return m*(p-p0)+s0 end | |
local OptimalPrice = (p1*s0-p0*s1)/(2*(s0-s1)) | |
local OptimalOutput = f(OptimalPrice) | |
print(('%.0f R$ = %.0f sold = %.0f R$ Revenue'):format(OptimalPrice, OptimalOutput, OptimalPrice*OptimalOutput)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment