I've never run into this problem before. The routine stops in the middle of execution @ the number 113383. If you inspect the code you'll see that the stopping condition in the for loop has clearly not been satified. To be honest, I'm baffled. I even ran the code on my other comp. Same results. My request is: someone paste the code into your IDE (or wherever) and see if the same thing happens.
It doesn't stop, it gets into an infinte loop, since long overflows and value of HOTPO gets negative for 113383.
Changing long to unsigned long works for 113383. I would suggest to use some bignum library if you want to continue (ttmath is a good start :) ).