input: n-bit integer X
output: list of prime factors and their multiplicity
acc = X
for i = 2 ... sqrt( X )
--count = 0
--while acc % i == 0
------acc = acc / i
------count = count + 1
--if count > 0
------print i (count)
I know that for the worst case, a n-bit integer is 2^n maximum.
So the time complexity for for i = 2 ... sqrt( X )
is 2^(n/2)-1
Now I'm really confused with the time complexity of while acc % i == 0
For the worst case, let's say that the n-bit number X is a prime. Then the while loop will not be executed at all. How can I define its time-complexity?
How can I find the Big-O of this algorithm? Is iit O(2^n) or O(2^(n/2))