in reply to Avoid keeping larger lists in Memory

One truth is that the largest prime factor of a number is always less than or equal to the square root of that number

There are two places you can change to reflect that truth and that will speed up your program (otherwise as is) a lot.

That wasnt quite right. In testing for a prime number you only have to test for factors below the square root of the number. If you find a factor below that point, the division of the original number by that factor results in another factor. That second factor may be the largest prime factor.

  • Comment on Re: Avoid keeping larger lists in Memory