50. All Factors of a Number

Acceptance — 0 accepted 0 submissions

Easy
LoopsMath
No companies listed
The PT teacher has n students and wants to arrange them in equal rows. Each possible row size is a factor of n.

Print all factors of n in increasing order.

Input Format
A single integer n.

Output Format
Print all factors of n in increasing order, separated by single spaces.

Constraints
• 1 ≤ n ≤ 10^5

Example 1

Input
12
Output
1 2 3 4 6 12

Explanation 12 can be split as 1, 2, 3, 4, 6 or 12 per row.

Example 2

Input
7
Output
1 7

Explanation 7 is prime, so only 1 and 7.

Example 3

Input
1
Output
1

Explanation 1 has only itself.

Acceptance —
Accepted 0
Submissions 0
Auto-save
Saved Ln 1, Col 1
Submit a solution to see its status here.
Input
Expected Output
1 2 3 4 6 12
No results yet
Run your code to test it against the sample cases.
Problem List