I come from a scientific background, so my approach to the solution of this problem is a little different.
It makes use of some numerical approximations, but that's not necessarily a bad thing, because it helps avoid singularities. So it could be a little more robust than other solutions presented here. It also has a little more functionality: Say you wanted to return three times a variable, you wouldnt want to write another function to do that for you, so now you just pass in how many times you want the variable repeated as the first parameter. Hope this helps! Cheers! import math def repeat(how_many_times, x): def f(n): return 1./(2**n) def summation(func, howmany): if howmany == 1: return func(1) else: return func(howmany) + summation(func, howmany-1) def eulerify(num): return abs(math.cos(math.pi) + 1j*(math.sin(math.pi))) * num def get_coefficient(multiplier): return eulerify(multiplier * summation(f, 100)) return int(eulerify(get_coefficient(how_many_times) * x)) On Fri, Oct 2, 2009 at 2:08 PM, Albert van der Horst <alb...@spenarnc.xs4all.nl> wrote: > In article > <fa454992-d61a-4fb7-b684-c8535bce5...@e18g2000vbe.googlegroups.com>, > daggerdvm <dagger...@yahoo.com> wrote: >>you brain needs error checking! > > Whose brain? At least I know this: > > Your brain is beyond repair. Go for a brain transplant. > > Groetjes Albert > > -- > -- > Albert van der Horst, UTRECHT,THE NETHERLANDS > Economic growth -- being exponential -- ultimately falters. > alb...@spe&ar&c.xs4all.nl &=n http://home.hccnet.nl/a.w.m.van.der.horst > > -- > http://mail.python.org/mailman/listinfo/python-list > -- http://mail.python.org/mailman/listinfo/python-list