In how many ways can 8 different numbers can be chosen from the first 49 positive integers such that the product of these numbers is divisible by 8?
The answer will be C(49,8) minus the number of ways there are of having no divisors by 8. No divisors by 8 can occur if there are:
a) no even numbers
b) one factor of 2 in one number
c) one factor of 2 in two numbers
d) two factors of 2 in one number
429555291
----------
zero2s = [n for n in range(1,50,2)]
one2s = [2*n for n in range(1,24,2)]
two2s = [4*n for n in range(1,12,2)]
threeOrMore2s = [8*n for n in range(1,7)]
len0 = len(zero2s)
len1 = len(one2s)
len2 = len(two2s)
len3 = len(threeOrMore2s)
a = combin(len0,8)
b = combin(len1,1) * combin(len0,7)
c = combin(len1,2) * combin(len0,6)
d = combin(len2,1) * combin(len0,7)
total = combin(49,8)
ans = total - a - b - c - d
print(ans)
----------
Check to see numbers are grouped appropriately:
print(zero2s)
print(one2s)
print(two2s)
print(threeOrMore2s)
print(len0,len1,len2,len3, len0+len1+len2+len3)
[1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49]
[2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46]
[4, 12, 20, 28, 36, 44]
[8, 16, 24, 32, 40, 48]
25 12 6 6 49
|
Posted by Larry
on 2024-07-20 10:55:35 |