All divisors of a natural number
Submissions: 1845   Accuracy:

55.99%

  Difficulty: School   Marks: 0
*School Problem's Submission isn't counted in score!
       

Given a natural number N, print all distinct divisors of it including 1 and the number itself.

Input:
The first line of input contains an integer T, denoting the number of testcases. The first line of each testcase is N, N is the number whose divisors are to be printed.

Output:
For each testcase in a new line, print all the divisors of the given number including 1 and the number itself separated by space.

Constraints:
1 <= T <= 100
1 <= N <= 108

Example:
Input:

3
100
10
125

Output:
1 2 4 5 10 20 25 50 100
1 2 5 10
1 5 25 125

Explanation:
Testcase 2:
The divisors of 10 are: 1 2 5 10.

** For More Input/Output Examples Use 'Expected Output' option **

Author: atharv


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.