The nested loop runs only in case of divisor of N, whenever i dividies N , the nested loop runs N times,
As divisor of any number are not equivalent to N , they may be less then sqrt(N)
And to find number of divisors of any number, it will take sqrt(N) complexity.
So overall lets say N have sqrt(N) divisors
Hence as per my knowledge , the overall complexity, of the above code is sqrt(N) * N
Not N^2.
Best complexity is o(N) in case of primes number, when N = prime , it have only two divisors in that case complexity is linear.