Algorithm to find nth root of a number
问题 I am looking for an efficient algorithm to find nth root of a number. The answer must be an integer. I have found that newtons method and bisection method are popular methods. Are there any efficient and simple methods for integer output? 回答1: #include <math.h> inline int root(int input, int n) { return round(pow(input, 1./n)); } This works for pretty much the whole integer range (as IEEE754 8-byte double s can represent the whole 32-bit int range exactly, which are the representations and