Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Tony van der Hoff Newsgroups: comp.lang.python Subject: Re: Trailing zeros of 100! Date: Sun, 03 Jan 2016 11:53:02 +0100 Lines: 25 Message-ID: References: <52ccbc4b-616b-4186-8802-97aaa5b0d9af@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: news.uni-berlin.de 00+eoZ0nqhL/SH4/NT10XwsBq51kNhop1qW4Za3Dh4MA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.042 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'exercise': 0.03; 'newbie': 0.05; 'undefined.': 0.09; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'math': 0.20; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'van': 0.26; 'but': 0.36; 'should': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:localdomain': 0.38; 'log': 0.38; 'why': 0.39; 'test': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'skip:u 10': 0.61; 'obvious': 0.76; '17:09': 0.84; 'from:addr:tony': 0.84 X-Virus-Scanned: Debian amavisd-new at mail.vanderhoff.org User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101203 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@vanderhoff.org Ariège, France |