On 02/01/16 17:56, Robin Koch wrote: > Am 02.01.2016 um 17:09 schrieb Tony van der Hoff: >> On 02/01/16 16:57, Robin Koch wrote: >>> sum([int(0.2**k*n) for k in range(1, int(log(n, 5))+1)]) >> >> But did you actually test it? > > Yes, should work for n >= 1. > > Why do you ask? > >From your original post:
How about: >>> from math import log >>> sum([int(0.2**k*n) for k in range(1, int(log(n, 5))+1)]) That would never work; n is undefined. Now, you may have left that as an exercise for the reader, but without warning, for an obvious newbie such as the OP, that would have been unnecessarily confusing. -- Tony van der Hoff | mailto:t...@vanderhoff.org Ariège, France | -- https://mail.python.org/mailman/listinfo/python-list