#!/usr/bin/lua
if #arg > 0 then
nolimit = false
upto = tonumber(arg[1])
else
nolimit = true
end
sum = 0.0
num = 1
cnt = 0
lst = 0.0
while nolimit or num <= upto do
for i = 1, num do
sum = sum + ( num / i )
cnt = cnt + 1
end
toprint = sum / cnt
print("up to " .. num .. ": " .. toprint .. ", diff to predecessor: " .. ( toprint - lst ) )
lst = toprint
num = num + 1
end
Let's peer review your method. Don't post the code, just your method. Then we evaluate, say, a perfect random number generator (just download a big list of numbers)Just wondering, given any two positive numbers in existence, what is their average ratio? I made a program that randomly generates ratios, and after using it a while, I think the answer is 7, but I have no idea why the answer is 7. Math sux.
If I understand the question I think it's just infinite. I may be wrong, it's long since I did exercises like that.Just wondering, given any two positive numbers in existence, what is their average ratio? I made a program that randomly generates ratios, and after using it a while, I think the answer is 7, but I have no idea why the answer is 7. Math sux.
But how large are the 2x random integers you take for those x divisions ? between 1 and 200000 or so?x is the number of ratios to include. y is the average.
but maybe it’s now a bit dangerous in Germany to post content whit Roms..