What is the time complexity of this Factorization program?
Your algorithm takes $O(X^{1/2})$ in the worst case, which isn't too bad, but it also takes $\Theta(X^{1/2})$ in the best case. That's because you always test divisibility by all numbers up to $X^{1/2}$ even when it is clear that you found all factors of X already. 

The loop testing acc % i = 0 is negligible, because X has at most $\log X$ factors.