List every divisor of n in ascending order in O(√n):
- loop
dfrom 1 whiled × d ≤ n - when
ddividesn, recorddin a small list andn / din a large list (skip it whend × d = n) - the answer is
smallfollowed bylargereversed
That gives sorted output without calling sort, because the small partners grow while their large partners shrink.