There exists positive integers m and n such that 2/m + 3/n = 1/16. Find the mean of the set of integers which contains all possible values of m and n.
I started with a brute force program and once large enough numbers were tested, the result appeared to be 244.6
But here is an analytic approach:
2/m + 3/n = 1/16
32n + 48m - nm = 0
This looks like a job for Simon's Favorite Factoring Trick
(32 - m)n + 48(m - 32) = -48*32
(48 - n)(32 - m) = 1536
The factors of 1536 are (+ or -)
1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1536
factors ; (n,m)
(1,1536); (47, -1504) ; reject since m < 0
(-1,-1536); (49, 1568); accept
(2,768); (46,-736) ; reject since m < 0
(-2,-768); (50,800); accept
Time for a program to automate going through all the possibilities.
(48 - n)(32 - m) = 1536
(n,m)
(49, 1568)
(50, 800)
(51, 544)
(52, 416)
(54, 288)
(56, 224)
(60, 160)
(64, 128)
(72, 96)
(80, 80)
(96, 64)
(112, 56)
(144, 48)
(176, 44)
(240, 40)
(304, 38)
(432, 36)
(560, 35)
(816, 34)
(1584, 33)
And the mean is indeed 244.6
-------------------
factors = [1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 1536]
revfacs = [1536, 768, 512, 384, 256, 192, 128, 96, 64, 48, 32, 24, 16, 12, 8, 6, 4, 3, 2, 1]
nmlist = []
means = []
for index, value in enumerate(factors):
n = 48 - factors[index]
m = 32 - revfacs[index]
if n>0 and m>0:
nmlist.append([n,m])
means.append((n+m)/2)
n = 48 + factors[index]
m = 32 + revfacs[index]
if n>0 and m>0:
nmlist.append([n,m])
means.append((n+m)/2)
print(nmlist)
print(sum(means) / len(means))
|
Posted by Larry
on 2025-04-14 08:36:54 |