[Tutor] Help

Andre Engels andreengels at gmail.com
Wed Jul 14 09:11:45 CEST 2010


On Tue, Jul 13, 2010 at 12:34 PM, Nitin Pawar <nitinpawar432 at gmail.com> wrote:
> Adding to what Andre said,
> another way of optimizing the problem would be
> storing the prime number in the range you want to check an array and see if
> the given number is divisible by any of those prime number

As I wrote, my code was not optimalized for either code size or
execution time. Other obvious speed-ups, apart from the one you
mention, are to only search up to the square root of the number
(rather than to the number minus 1), and to immediately break out of
the loop once a divisor has been found.


-- 
André Engels, andreengels at gmail.com


More information about the Tutor mailing list