i am not able to understand how the complexity of Naive approach is 0 (n) and optimised approach is 0(sqrt(n)) though our value of n keeps on reducing
Complexity of Naive and Optimised approach?
Consider the case when n itself is prime, in that case you would have to run the naive approach till n but in optimised approach you only go till sqrt(n)