Hacker News new | ask | show | jobs
by DoreenMichele 3089 days ago
Tip: you only need to factor it to the midpoint. Factors occur in pairs. Identifying the smallest factors will automatically identify the largest.

100 is divisible by 2. 2x50=100

No need to wonder if 51-99 are factors. They aren't. 50 is your largest factor.

1 comments

Indeed - you can even extend this idea to only identify factors less than or equal to the square root - all factors greater than this have a matching factor less than the square root.
You can also prime factor the larger factors. Once you have all the primes, you can build the other numbers.

50 = 2x5x5 So 100 = 2x2x5x5

You can build your other factors of 4,10, 20 and 25 by multiplying the subsets.