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


Groups > comp.lang.python > #8142 > unrolled thread

Re: 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)?

Started byChris Angelico <rosuav@gmail.com>
First post2011-06-22 09:02 +1000
Last post2011-06-22 09:02 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: 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 09:02 +1000

#8142 — Re: 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)?

FromChris Angelico <rosuav@gmail.com>
Date2011-06-22 09:02 +1000
SubjectRe: 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)?
Message-ID<mailman.250.1308697366.1164.python-list@python.org>
Oops, realized after posting that there's a bug in my code - it
returns 1 for a perfect square. Need another check in the 'while'
loop, thus:

On Wed, Jun 22, 2011 at 8:59 AM, Chris Angelico <rosuav@gmail.com> wrote:
> exec 600851475143; for (int i=2;i<ret;++i) while (ret%i==0 && ret>i) ret/=i
>
>  while not ret%i and ret>i:

Definitely room for improvement here!

ChrisA

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web