After my failed attempt at trying to implement the ECM, I started working on the quadratic sieve. It works, but the bottleneck is finding smooth values over the factor base.
The way I implemented it now, it generates 250,000 values of X, then calculates Y as:
Y = (X + ceil(sqrt(n)))^2 - n
Where n is the number to be factored. I then iterate through the 250,000 values for Y, and look for the first divisible by a factor in the factor base (p), then divide every p'th element by p. I repeat this for each factor in the factor base.
Then I search for the values of Y which equal 1, and add them to an array, then repeat the above until I have as many as in the factor base + 1.
This process is really slow, I was hoping for suggestions of ways to speed this up, or an explanation on how to generate polynomials so I can try and implement the MPQS. I've read some explanations, but they focus more on the mathematics rather than the 'mechanics' of generating them.