I think I should say it is linear time complexity. The number of iteration for those 3 while loops depend on how many prime factors compose the input. For example, if the input consists of k prime factors, then the while loops iterates k times. So, I think the complexity is O(k).