Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8140
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.009 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; 'wed,': 0.03; 'python:': 0.05; 'exec': 0.07; 'python': 0.08; '(int': 0.09; 'am,': 0.14; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; 'cares': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:was': 0.16; 'simpler': 0.19; "what's": 0.23; "i'm": 0.27; 'message-id:@mail.gmail.com': 0.28; 'thanks': 0.28; 'problem': 0.28; 'received:209.85.214': 0.28; 'subject:How': 0.30; '(since': 0.30; 'porting': 0.30; 'solved': 0.30; 'to:addr:python-list': 0.33; 'received:google.com': 0.37; 'received:209.85': 0.37; 'everyone.': 0.37; 'subject:can': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'some': 0.38; 'subject: (': 0.39; "i'd": 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.39; 'subject:, ': 0.60; 'your': 0.60; 'john': 0.62; 'bring': 0.64; 'fun!': 0.67; 'subject:over': 0.84; 'subject:much': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=maxFHyJoMzAWqEDcDW4BjbRkSUFwuLu9ptU+aCHVUCw=; b=dEfswvlgZH9zCHKPGuW5BoHr36hm7GPAbbshpdsPgLrsMQm/d10aBDyXFrwzbqh4rQ ZVZCs+qvwd5rAEA+alIpDKfQS2+I9TykTpC5Xjq3YomqxyUNQDlUTMNyjKlTNyoai6ai 3yDAPrBt4mZhDzZq5F/fKj0c+U4w3Lgole7KY= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=M7odXkwNjxl2CvBoOdl/rUxJhfzu4tn2p6abyEJ2gi7pDAOgUjk6/M6t5xdbttpnOI OeUBnEHnu1tfGeVJ/4Eb7zbEPhjE56k8iZJ+GcDnDKa4jDm6tK254oW9iGnC7tKgXjeB sgWb88gCz51nLCoxQMPdtXVvy9CVngRTaolkk= |
| MIME-Version | 1.0 |
| Date | Wed, 22 Jun 2011 08:59:34 +1000 |
| Subject | Finding greatest prime factor, was Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)? |
| From | Chris Angelico <rosuav@gmail.com> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.248.1308697176.1164.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1308697177 news.xs4all.nl 49174 [::ffff:82.94.164.166]:41767 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:8140 |
Show key headers only | View raw
On Wed, Jun 22, 2011 at 7:48 AM, John Salerno <johnjsal@gmail.com> wrote:
> Thanks for the all the advice everyone. Now I'm on to problem #4, and
> I'm stumped again, but that's what's fun! :)
So now that you've solved it, I'd like to see some fast one-liners to
do the job. (Since Python cares about whitespace, it might not
_technically_ fit on one line, but in the spirit of one-liners, try to
keep it short.)
Here's what I did in Pike, very quickly:
exec 600851475143; for (int i=2;i<ret;++i) while (ret%i==0) ret/=i
Porting it to Python:
ret,i=600851475143,2
while i<ret:
while not ret%i:
ret//=i
Bring on your simpler solutions!
ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Finding greatest prime factor, was Re: sorry, possibly too much info. was: Re: How can I speed up a script that iterates over a large range (600 billion)? Chris Angelico <rosuav@gmail.com> - 2011-06-22 08:59 +1000
csiph-web