I need help with finding out the time complexity of the first and second loop(the nested for-while loop), I'm not so sure of my answers:
for the first loop: O(log n)
for the second loop: O(sqrt(n) logn)
The Code:
public static int findLength(int n){
int length = 0;
//FIRST LOOP
while (n%2==0){
length++;
n /= 2;
}
//SECOND LOOP
for (int i = 3; i <= Math.sqrt(n); i+= 2) {
while (n%i == 0) {
length++;
n /= i;
}
}
if (n > 2)
length++;
return length;
}