Quote from n00b7r4d3r:
That is good news. I probably could have just copied one off the internet but I figured it would be better to code up one myself so I would understand exactly what it was doing and would be able to modify it.
I was surprised that I got it working just because its the kind of thing where you can have one tiny logic error and the whole thing won't work.
Also translating it from the math notation to code is hard on the head.