 
  
try testing before posting ;)
I just compiled it (compiled fine) and ran it..
Judging by the outputs it's alright :)
Cheers!
 
 
 
  
I think that you may have trouble with div <= sqrt(n), because of round-off errors.
Besides that it is correct, but could be faster.
Last edited on