#5 - Find Divisors of Number

Print all the divisors of the given numbers.

A divisor is a number that gives remainder as zero when divided.

Ex:

Lets divide 15 by 3, we will get Quotient = 5 and Remainder = 0.

Then 3 is divisor of 15.

Lets take another example

Lets divide 15 by 4, We will get Quotient = 3, Remainder = 3

Here Remainder is not Zero, So 4 is not divisor of 15.


Example 1:

Input: 12

Output: 1, 2, 3, 4, 6, 12

12 / 1 -> remainder is zero -> so 1 is divisor of 12

12 / 2 -> remainder is zero -> so 2 is divisor of 12

12 / 3 -> remainder is zero -> so 3 is divisor of 12

12 / 4 -> remainder is zero -> so 4 is divisor of 12

12 / 6 -> remainder is zero -> so 4 is divisor of 12

12 / 12 -> remainder is zero -> so 4 is divisor of 12


Example 2:

Input: 15

Output:

1, 3, 5, 15


Video Solution

Last updated