You are given an integer n
. Your task is to implement a function printAllDivisors
that prints all the divisors of n in ascending order.
n
(1 <= n <= 10^6): An integer for which you need to find and print all divisors.
Print the divisors of n in ascending order, separated by spaces.
Example 1:
Input n:
12
Output:
1 2 3 4 6 12
Explanation:
The divisors of 12 are 1, 2, 3, 4, 6, and 12.
Example 2:
n = 30
Output:
1 2 3 5 6 10 15 30
Explanation:
The divisors of 30 are 1, 2, 3, 5, 6, 10, 15, and 30.
Note:
- You should print the divisors in ascending order.
- Do not print duplicates if there are any.
- Only print the divisors separated by spaces.