Skip to content

Instantly share code, notes, and snippets.

@lhog
Last active July 15, 2018 13:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lhog/7c6c019e536131387cf855b032eaac92 to your computer and use it in GitHub Desktop.
Save lhog/7c6c019e536131387cf855b032eaac92 to your computer and use it in GitHub Desktop.
--Inputs
LEVELS = 20
x= 0.15
--Vars
rest = 1.0
sum = 0
array = {}
table.insert(array, 0.0)
for i = 1, LEVELS - 1 do
sum = sum + rest * x
table.insert(array, sum)
rest = rest * (1.0-x)
end
mul = 1 / array[#array]
str = ""
for i = 1, LEVELS do
if i < LEVELS then
str = str .. (array[i] * mul) ..", "
else
str = str .. (array[i] * mul)
end
end
print(str)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment