I don't have a maths background but I'm solving problems on the awesome Project Euler .net in JavaScript as programming practice.
I don't want to link directly to the question or post it verbatim here because that defeats the point behind working out the puzzles but...
As I think I understand it, all factors of a number can be generated from the prime divisors of that number.
I can generate primes easily for numbers around 1e7 (Code is in JavaScript):
function primes(y) { for (var i=2; i<=y; i++) { if (y % i === 0) { console.log(i); y = y/i; } } }
What I don't really understand is how I can use those primes to generate all other factors.
Because the question is in regards to a number with more than 500 divisors the brute force approach of (y % i === 0)
just won't work.
Please help me with what I'm sure are terrible assumptions.
This is the closest I've come to what I perhaps might need to do but still don't understand the principle behind it.
http://en.wikipedia.org/wiki/Trial_division
Thanks.