Regarding complexity

if we want to find the divisors for single query then iteration will be better than find through prime sieve?

yes @CHANDU_0556 for single query iteration root n method works better.
i hope your doubt is cleared if yes dont forget to mark it as resolved :smiley: