Ok so now your interviewer asks you to write a program to find all the divisors of a number. What would be your solution.
Example:
if NUM = 6
Divisors of 6 are 1 2 3 6.
Time Complexity : Θ(n)
Space Complexity: O(1)
Time Complexity : Θ(√n)
This solution does not print the divisors in sorted order.
Time Complexity : Θ(√n)
Space Complexity : O(1)
Do you have a better solution in mind?
Do share in the comments!
Top comments (0)