Project euler problem #255 is quite mathematical. I figured out how it is done for given example. Since I am a newbie in Python, I am not sure how to handle long range values. Below is the solution I have. But how does it work for 10^13 and 10^14?
def ceil(a, b):
return (a + b - 1) / b;
def func(a, b):
return (b + ceil(a, b)) / 2;
def calculate(a):
ctr = 1;
y = 200;
while 1:
z = func(a, y);
if z == y:
return ctr;
y = z;
ctr += 1;
result = sum(map(calculate, xrange(10000, 100000))) / 9e4;
print "%.10f" % result;
This gives 3.2102888889.