Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Mark Lawrence Newsgroups: comp.lang.python Subject: Re: Trailing zeros of 100! Date: Sat, 2 Jan 2016 15:30:09 +0000 Lines: 61 Message-ID: References: <52ccbc4b-616b-4186-8802-97aaa5b0d9af@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de iSJaO/j/DbLqEhM7Svrnlgk7cQD1Mv+K3hW+jUvX09hw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'resulting': 0.04; 'from:addr:yahoo.co.uk': 0.05; 'newbie': 0.05; 'trailing': 0.07; 'posting.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'zeros': 0.09; 'python': 0.10; 'jan': 0.11; ':-)': 0.12; '"0"': 0.16; '13:14,': 0.16; '2016': 0.16; 'failed.': 0.16; 'preserved': 0.16; 're,': 0.16; 're.search(': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'string': 0.17; 'module,': 0.18; 'input': 0.18; 'language': 0.19; '>>>': 0.20; 'math': 0.20; 'lawrence': 0.22; 'text,': 0.22; 'trying': 0.22; 'help.': 0.23; 'sat,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'regular': 0.29; 'indentation': 0.29; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.30; 'skip:s 30': 0.31; 'language.': 0.32; 'url:python': 0.33; "i'll": 0.33; 'url:listinfo': 0.34; 'me?': 0.34; 'i.e.': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'lines': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'version': 0.38; 'thank': 0.38; 'hi,': 0.38; 'end': 0.39; 'rather': 0.39; 'url:mail': 0.40; 'to:addr:python.org': 0.40; 'mark': 0.40; 'some': 0.40; 'show': 0.62; 'charset:windows-1252': 0.62; 'more': 0.63; 'our': 0.64; '>>>>>': 0.66; 'chinese': 0.79; 'here!': 0.84; 'pythonistas,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: 212.88.57.246 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.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:101153 On 02/01/2016 13:14, yehudak . wrote: > Vlastimil, > Thank you so much, but... > All that is Chinese for me. > Can you show a 'normal' Python code for me? > > Yehuda > > On Sat, Jan 2, 2016 at 2:44 PM, Vlastimil Brom > wrote: > >> 2016-01-02 12:49 GMT+01:00 : >>> Hi, newbie here! >>> I'm trying to write a python program to find how many trailing zeros are >> in 100! (factorial of 100). >>> I used factorial from the math module, but my efforts to continue >> failed. Please help. >>> >>> Thank you, >>> Yehuda >>> -- >>> https://mail.python.org/mailman/listinfo/python-list >> >> Hi, >> rather an illustration of the available tools in python, than a >> (submittable) solution: >> >>>>> import re, math >>>>> len(re.search(r"0*$", str(math.factorial(100))).group()) >> 24 >> [or the same code on more lines with some indentation - if it is >> preserved via e-mail] >>>>> len( >> ... re.search( >> ... r"0*$", >> ... str( >> ... math.factorial(100) >> ... ) >> ... ).group() >> ... ) >> 24 >>>>> >> >> I.e. You need the length of the string resulting as the match of the >> regular expression search for a pattern representing zero or more "0" >> at the end of the input text, which is the string version of 100! >> >> Of course, there are other ways to get this result :-) >> >> regards, >> vbr >> I'll explain it if you stop top posting. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence