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