What is the time complexity of log10 function in cmath ? Its nowhere mentioned on the internet. Does anyone know for sure ?
Later edit: My initial question was if the following code is faster.
int numOfDigits(int n) {
return (int)log10(n) + 1;
}
than this
int numOfDigits(int n) {
int count = 0;
while(n) {
count ++;
n /= 10;
}
return 0;
}
i know for sure that the second function time complexity is O(log(n)). What's the time complexity of the first function.