Finding Divisors of a Number
hebaShakeel
Posted on June 18, 2022
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!
💖 💪 🙅 🚩
hebaShakeel
Posted on June 18, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
computerscience Episode #6: Increasing Access to Computer Science Education with Diana Kris Navarro
April 18, 2022