Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'float': 0.07; 'happen?': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'skip:2 30': 0.09; 'subject:number': 0.09; 'python': 0.11; '>on': 0.16; 'message-id:@4ax.com': 0.16; 'mine.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'seconds,': 0.16; 'subject:skip:m 10': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'bit': 0.19; '>>>': 0.22; 'url:home': 0.24; 'paul': 0.24; 'header:X-Complaints-To:1': 0.27; 'skip:p 30': 0.29; 'code': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'writes:': 0.31; 'subject:all': 0.32; 'older': 0.33; 'there,': 0.34; "i'd": 0.34; 'but': 0.35; 'version': 0.36; 'charset:us-ascii': 0.36; 'seconds': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'skip:2 20': 0.60; 'times': 0.62; 'more': 0.64; 'laptop': 0.65; 'skip:1 20': 0.65; '2015': 0.84; 'double,': 0.84; 'subject:find': 0.84; 'received:108': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: find all multiplicands and multipliers for a number Date: Sat, 11 Apr 2015 12:41:24 -0400 Organization: IISS Elusive Unicorn References: <890bd388-f50a-4dec-9ef5-27715427472a@googlegroups.com> <55288135$0$12997$c3e8da3$5496439d@news.astraweb.com> <87egnrb3il.fsf@jester.gateway.sonic.net> <5528ceab$0$13013$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-108-79-223-87.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 6.00/32.1186 X-No-Archive: YES 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: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428770707 news.xs4all.nl 2861 [2001:888:2000:d::a6]:34730 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88830 On Sat, 11 Apr 2015 17:35:07 +1000, Steven D'Aprano declaimed the following: >On Sat, 11 Apr 2015 04:08 pm, Paul Rubin wrote: > >> Steven D'Aprano writes: >>> It may be a bit slow for very large numbers. On my computer, this takes >>> 20 seconds: >>> py> pyprimes.factors.factorise(2**111+1) >>> [3, 3, 1777, 3331, 17539, 25781083, 107775231312019L] >> >> This takes about 4 seconds on a Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz >> laptop (64 bit linux): > >Nice for some who have fast machines, but on my old jalopy, your code takes >110 seconds, more than five times slower than mine. It also returns the >wrong result: > >[3, 3, 3, 3, 7, 19, 73, 87211, 262657, 1.4411518807585587e+17] > >Oops, you have a float in there, how did that happen? > Off the top of my head -- I'd suspect an older version of Python that promoted 2**111 to a double, rather than to a Long-Int. >>> 2**111 2596148429267413814265248164610048L (forcing float) >>> 2.0**111 2.596148429267414e+33 >>> -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/