Check all are factors in the list
Problem to check all the list elements are divisible by k or not.
Example-1:
Input : n = [ 1, 2, 4, 8] , k = 8 Output : True Explain : k is divisible by all the list elements. So It's True.
Example-2:
Input : n = [ 1, 3, 5] , k = 5 Output : False Explain : K is not divisible by 3. So It's False.
Solution
n = [ 1, 2, 4, 8] k = 8 a = all([k % x == 0 for x in n]) print(a)
Output
True