Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
indexerror and optimization
#5
The reason you are being asked to do such a large number is specifically because brute force methods like this won't work. You are required to come up with a more efficient method.

One relatively efficient method would be to find all possible prime factors that are less than or equal to the square root of the number. Then check only those numbers.

First look up how to write a prime sieve (Eratosthenes will work). Then for each number in the sieve check if it is a factor and divide the number if so.
Reply


Messages In This Thread
indexerror and optimization - by mcrazy1111 - Jan-19-2018, 03:35 PM
RE: indexerror and optimization - by sparkz_alot - Jan-19-2018, 03:40 PM
RE: indexerror and optimization - by mcrazy1111 - Jan-19-2018, 04:05 PM
RE: indexerror and optimization - by wavic - Jan-19-2018, 04:43 PM
RE: indexerror and optimization - by Mekire - Jan-19-2018, 10:21 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020