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


Groups > comp.lang.python > #101176

Re: Trailing zeros of 100!

From Robin Koch <robin.koch@t-online.de>
Newsgroups comp.lang.python
Subject Re: Trailing zeros of 100!
Date 2016-01-03 01:02 +0100
Organization albasani.net
Message-ID <n69oev$uv8$1@news.albasani.net> (permalink)
References (2 earlier) <mailman.162.1451745109.11925.python-list@python.org> <n68s1t$ke9$1@news.albasani.net> <mailman.172.1451753180.11925.python-list@python.org> <n68vgc$qi6$1@news.albasani.net> <mailman.184.1451771860.11925.python-list@python.org>

Show all headers | View raw


Am 02.01.2016 um 22:57 schrieb Chris Angelico:
> On Sun, Jan 3, 2016 at 3:56 AM, Robin Koch <robin.koch@t-online.de> 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?
>
> Your "should work" does not sound good as a response to "actually
> test". Normally I would expect the response to be "Yes, and it worked
> for me" (maybe with a log of an interactive session).

Well, honestly, I trusted my math and didn't thought much about the 
technical limitations.

I only tried values from 1 to 100 and then again 12345, I believe, to 
test the algorithm.

 > Floating point
> can't represent every integer, and above 2**53 you end up able to
> represent only those which are multiples of ever-increasing powers of
> two; 100! is between 2**524 and 2**525, so any float operations are
> going to be rounding off to the nearest 2**471 or thereabouts.
> That's... a lot of rounding. That's like trying to calculate whether
> pi is rational, but basing your calculations on the approximation
> 3.14. :)

When I find more time I take a closer look at it. Thank you (and 
Bernardo) for your clarification. I hope everyone who read my article 
reads yours, too and learns from it. ;-)

-- 
Robin Koch

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