Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101150

Re: Trailing zeros of 100!

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Subject Re: Trailing zeros of 100!
Date Sat, 2 Jan 2016 09:57:26 -0500
Lines 71
Message-ID <mailman.166.1451746655.11925.python-list@python.org> (permalink)
References <52ccbc4b-616b-4186-8802-97aaa5b0d9af@googlegroups.com> <CAHzaPEOzP+DZDHOV7s1tDA0AUNhFdBUJKZWCJ5W9F8ec6aH-JA@mail.gmail.com> <CAE3ie42VkmUKOMzp18aHntL26hon6spNOXxJKQQGUsB9XuV2-g@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de nRyT25ye3sWeOo1YEsHRggTR3AP1ii/+ExlzpJU8Vstw==
Return-Path <joel.goldstick@gmail.com>
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; 'received:209.85.223': 0.03; 'resulting': 0.04; 'newbie': 0.05; 'trailing': 0.07; 'cc:addr:python-list': 0.09; 'output,': 0.09; 'question?': 0.09; 'zeros': 0.09; 'python': 0.10; 'jan': 0.11; ':-)': 0.12; '&gt;&gt;&gt;': 0.15; '"0"': 0.16; '2016': 0.16; 'cc:name:python': 0.16; 'contrived': 0.16; 'count,': 0.16; 'failed.': 0.16; 'forward:': 0.16; 'preserved': 0.16; 're,': 0.16; 're.search(': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reversing': 0.16; 'slicing,': 0.16; 'wrote:': 0.16; 'string': 0.17; 'module,': 0.18; 'skip:l 30': 0.18; 'written,': 0.18; '&gt;': 0.18; 'email addr:gmail.com&gt;': 0.18; 'input': 0.18; '>>>': 0.20; 'math': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'text,': 0.22; 'trying': 0.22; 'am,': 0.23; 'help.': 0.23; 'sat,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'message-id:@mail.gmail.com': 0.27; 'regular': 0.29; 'indentation': 0.29; "i'm": 0.30; 'url:mailman': 0.30; 'code': 0.30; 'push': 0.30; 'version,': 0.30; 'skip:s 30': 0.31; 'url:python': 0.33; 'url:listinfo': 0.34; 'me?': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'i.e.': 0.35; 'problem.': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'lines': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'version': 0.38; 'received:209': 0.38; 'wrong': 0.38; 'thank': 0.38; 'hi,': 0.38; 'end': 0.39; 'rather': 0.39; 'url:mail': 0.40; 'some': 0.40; 'your': 0.60; 'show': 0.62; 'more': 0.63; 'skip:\xc2 10': 0.67; 'chinese': 0.79; '(hint:': 0.84; 'here!': 0.84; 'to:none': 0.91; 'joel': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=cmHkF+1qhy2m7wEVpp7By7WGx1ZR1bdBnBk9G7e8/+4=; b=gqO6geIceES/796zP6aNl9xK0ukNnCcpVQKM0FrpAC0auO3TTtjyhKef2pcTdcz4Pv k1FAd/c5AyyP7sJJ9c/0wDCTETtW4WzPp2omVhhdz35I60NNrgxbVaHRL39G6c+NGTHJ JuXgf8AnvZQekE/aiPG7iyQu+R/bbagFrhd2ZUbbUhQ7aW93ZHJfmcwb+I8AFSQZ5neZ zvRoufVulifPcERN7iWMQH6Nl+ejwT0vKXkSMqC3lrpIfrjtcuUDaQ+EMWGS0BvRldLv 6DZAaojVGEmNez0wB3/or0DbRMb7Qz7RMOmia6hQvVlwnit9XWdznKl6GDtrRAIcPRzu 5zLg==
X-Received by 10.107.30.80 with SMTP id e77mr74153169ioe.180.1451746646076; Sat, 02 Jan 2016 06:57:26 -0800 (PST)
In-Reply-To <CAE3ie42VkmUKOMzp18aHntL26hon6spNOXxJKQQGUsB9XuV2-g@mail.gmail.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.20+
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:101150

Show key headers only | View raw


On Sat, Jan 2, 2016 at 8:14 AM, yehudak . <katye2007@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.brom@gmail.com>
> wrote:
>
> > 2016-01-02 12:49 GMT+01:00  <katye2007@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Trailing zeros of 100! katye2007@gmail.com - 2016-01-02 03:49 -0800
  Re: Trailing zeros of 100! David <bouncingcats@gmail.com> - 2016-01-02 23:19 +1100
  Re: Trailing zeros of 100! katye2007@gmail.com - 2016-01-02 04:34 -0800
  Re: Trailing zeros of 100! Vlastimil Brom <vlastimil.brom@gmail.com> - 2016-01-02 13:44 +0100
  Re: Trailing zeros of 100! "yehudak ." <katye2007@gmail.com> - 2016-01-02 15:14 +0200
    Re: Trailing zeros of 100! Robin Koch <robin.koch@t-online.de> - 2016-01-02 16:57 +0100
      Re: Trailing zeros of 100! Tony van der Hoff <tony@vanderhoff.org> - 2016-01-02 17:09 +0100
        Re: Trailing zeros of 100! Robin Koch <robin.koch@t-online.de> - 2016-01-02 17:56 +0100
          Re: Trailing zeros of 100! Bernardo Sulzbach <mafagafogigante@gmail.com> - 2016-01-02 15:24 -0200
          Re: Trailing zeros of 100! Chris Angelico <rosuav@gmail.com> - 2016-01-03 08:57 +1100
            Re: Trailing zeros of 100! Robin Koch <robin.koch@t-online.de> - 2016-01-03 01:02 +0100
              Re: Trailing zeros of 100! Ben Finney <ben+python@benfinney.id.au> - 2016-01-03 11:20 +1100
              Re: Trailing zeros of 100! srinivas devaki <mr.eightnoteight@gmail.com> - 2016-01-03 07:16 +0530
          Re: Trailing zeros of 100! Tony van der Hoff <tony@vanderhoff.org> - 2016-01-03 11:53 +0100
  Re: Trailing zeros of 100! Joel Goldstick <joel.goldstick@gmail.com> - 2016-01-02 09:57 -0500
  Re: Trailing zeros of 100! Vlastimil Brom <vlastimil.brom@gmail.com> - 2016-01-02 16:24 +0100
  Re: Trailing zeros of 100! Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-01-02 15:30 +0000
  Re: Trailing zeros of 100! Robin Koch <robin.koch@t-online.de> - 2016-01-02 16:54 +0100
    Re: Trailing zeros of 100! Peter Otten <__peter__@web.de> - 2016-01-02 18:18 +0100
  Re: Trailing zeros of 100! Tim Chase <python.list@tim.thechases.com> - 2016-01-02 10:33 -0600
  Re: Trailing zeros of 100! "yehudak ." <katye2007@gmail.com> - 2016-01-02 19:34 +0200
  Re: Trailing zeros of 100! Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-01-02 17:44 +0000
    Re: Trailing zeros of 100! Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-01-03 00:36 +0100
  Re: Trailing zeros of 100! Serhiy Storchaka <storchaka@gmail.com> - 2016-01-02 20:28 +0200
  Re: Trailing zeros of 100! Vlastimil Brom <vlastimil.brom@gmail.com> - 2016-01-02 19:29 +0100
  Re: Trailing zeros of 100! "yehudak ." <katye2007@gmail.com> - 2016-01-02 22:02 +0200
  Re: Trailing zeros of 100! "yehudak ." <katye2007@gmail.com> - 2016-01-02 22:09 +0200
  Re: Trailing zeros of 100! Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-01-02 21:25 +0000
  Re: Trailing zeros of 100! Mark Lawrence <breamoreboy@yahoo.co.uk> - 2016-01-02 21:26 +0000

csiph-web