Array ( [0] => [1] => questions [2] => Basic [3] => Divine-Divisor ) Codevita Previous Questions | Divine Divisor | THE INQUISITIVE





Divine Divisor

LEVEL:Beginner

Description

Print a line containing all the divisors in increasing order separated by space.

Input Format

The first line of input contains an integer 'N' denoting the number.

Output Format

Print a line containing all the divisors in increasing order separated by space.


Example 1:

Input
10
Output
1 2 5 10
Example 2:

Input
36
Output
1 2 3 4 6 9 12 18 36 
Example 3:

Input
72
Output
1 2 3 4 6 8 9 12 18 24 36 72 

oops

Login to see Discussion




Approach

Iterate a loop from 1 to sqrt(n) and check whether n%i==0 or not.
if it is zero add i to list1 and add n/i to list2.
print list1 and reversed list of list2 as factors of n.


Note :

Let us know if you can come up with a better approach, mail us at support@theinquisitive.in Your approach will be reviewed and posted with credits to you.

oops

Login to see Solution