On Sat, Jan 2, 2016 at 8:14 AM, yehudak . <katye2...@gmail.com> 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 <vlastimil.b...@gmail.com> > wrote: > > > 2016-01-02 12:49 GMT+01:00 <katye2...@gmail.com>: > > > 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 > > > -- > https://mail.python.org/mailman/listinfo/python-list > Can you improve your question? Which python version, which os are standard to tell. Also, show the code you have written, its output, and what you think is wrong with it. This might be homework, since it is a very contrived problem. But to push you forward: Can you get the factorial? Can you get the string of that result? Do you know about lists, and slicing, and reversing a list (hint: a = "123", b = a[::-1] will return "321" If you know these concepts, and know how to loop and count, you can solve your puzzle -- Joel Goldstick http://joelgoldstick.com/stats/birthdays -- https://mail.python.org/mailman/listinfo/python-list