not getting output
Kth root (divide and conquer)
@souravraj024
There are some mistakes in your code:-
- You are not calculating mid, inside the while loop, also calculate it in this way for avoiding overflow.
mid = start + (end-start)/2; - end variable should be initialized as n not n-1 as it can have this value.
- Also keep saving value in x variable even in the case of pow(mid,k)<n , because the condition is x^k <=n as given in question.
Do these corrections then it will be fine
yes , now the code is giving correct output . Thanks
1 Like