Trailing zeros of 100!

Tony van der Hoff tony at vanderhoff.org
Sun Jan 3 05:53:02 EST 2016


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:tony at vanderhoff.org
Ariège, France     |



More information about the Python-list mailing list