In how many ways can 6 different numbers be chosen from the first 25 positive integers such that the product of these numbers is a power of 6?
Note: This problem is adapted from a regional math competition for students up to grade 9 and calculators were not allowed.
I also misread this initially.
I get 18 ways:
set product power
[1, 2, 3, 4, 6, 9] 1296 = 6^ 4
[1, 2, 3, 6, 9, 24] 7776 = 6^ 5
[1, 2, 3, 6, 12, 18] 7776 = 6^ 5
[1, 2, 3, 8, 9, 18] 7776 = 6^ 5
[1, 2, 4, 6, 9, 18] 7776 = 6^ 5
[1, 2, 6, 9, 18, 24] 46656 = 6^ 6
[1, 3, 4, 6, 9, 12] 7776 = 6^ 5
[1, 3, 4, 9, 18, 24] 46656 = 6^ 6
[1, 3, 6, 9, 12, 24] 46656 = 6^ 6
[1, 3, 6, 9, 16, 18] 46656 = 6^ 6
[1, 3, 8, 9, 12, 18] 46656 = 6^ 6
[1, 4, 6, 9, 12, 18] 46656 = 6^ 6
[1, 6, 9, 12, 18, 24] 279936 = 6^ 7
[2, 3, 4, 9, 12, 18] 46656 = 6^ 6
[2, 3, 6, 8, 9, 18] 46656 = 6^ 6
[2, 3, 9, 12, 18, 24] 279936 = 6^ 7
[3, 4, 6, 9, 18, 24] 279936 = 6^ 7
[3, 6, 8, 9, 12, 18] 279936 = 6^ 7
------------
def product(aList):
p = 1
for i in aList:
p *= i
return p
def prime_factor(n):
""" for integer n, return a list of all the prime factors """
top = n // 2
factors = []
for i in range(2,top+1):
while n/i % 1 == 0:
factors.append(int(i))
n = n/i
if n == 1:
return factors
if n != 1:
factors.append(int(n))
return factors
import math
from itertools import combinations
maxProd = 25*24*23*22*21*20
minProd = 1*2*3*4*5*6
highestPower = int( math.log(maxProd,6))
lowestPower = int( math.log(minProd,6))+1
nums = [i for i in range(1,26)]
powers = [6**i for i in range(lowestPower, highestPower + 1)]
for comb in combinations(nums,6):
if product(list(comb)) in powers:
print(list(comb), product(list(comb)), ' = 6^',round(math.log(product(list(comb)), 6)))
|
Posted by Larry
on 2023-05-08 10:50:35 |