Array ( [0] => [1] => questions [2] => Strings [3] => Divine-Divisor )
Print a line containing all the divisors in increasing order separated by space.
The first line of input contains an integer 'N' denoting the number.
Print a line containing all the divisors in increasing order separated by space.
10
1 2 5 10
36
1 2 3 4 6 9 12 18 36
72
1 2 3 4 6 8 9 12 18 24 36 72
Login to see Discussion
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.
Login to see Solution