Factors of a number
Problem to find the Factors of the given number.
Example-1:
Input : n = 16 Output : [ 1, 2, 4, 8, 16] Explain : The 16 divisible numbers are [1,2,4,8,16].
Example-2:
Input : n = 7 Output : [ 1, 7] Explain : The 7 divisible numbers are [1,7].
Solution
n = 16 l = [] for i in range(1,n+1): if(n % i == 0): l.append(i) print(l)
Output
[1,2,4,8,16]