@Tin_Tin: You need not do a search from y to x in order to test for primality. y to x / 2 would be sufficient (if q is very large, you may need to google for more efficient deterministic or probabilistic algos). Also, there's a bug that limits the output to the first two factors of the first composite number. =)
[ simon.cpu ]




Reply With Quote
and another thing... altho naa ang solution, but much better if it's fast and efficient