Find all triplets (x, y, z) of positive integers that satisfy this equation:
2x+4y+8z= 328
I did both analytic and a computer program, guess which way was faster.
Analytic Solution:
Powers of 2 are all either 1 or 2 mod 3
328 is 1 mod 3
So, of (x,y,z), two must be 1 mod 3 and one must be 2 mod 3.
Also their last digits must add to 8.
The candidates for addends are limited to:
1 1 1
2 4 8
4 16 64
8 64
16 256
32
64
128
256
The 1's will not be participating today, since one of them would make the sum odd, and two of them would make the third number be 326 which is not on the list. The 1's are actually excluded since the exponents cannot be zero.
The final digits of addends can only be 2,4,6,8 which can only add to 8 mod 10 by summing:
(2,8,8) or (4,6,8)
(2,2,4) is out because only one of the three lists has a 2.
(6,6,6) is out because no power of 8 on the list ends with 6
case 1: (2,8,8)
one of the 8's must be 8 (8^1)
the other 8 must be either 8 or 128 (2^3 or 2^7)
328 - (8+8) = 312 rejected (also both 8 and 8 are 2 mod 3)
328 - (8+128) = 192 rejected (also both 8 and 128 are 2 mod 3)
case 2: (4,6,8)
ending in 4: only 4 and 64, both are 1 mod 3
ending in 6: 16 and 256, both are 1 mod 3
ending in 8: 8 and 128, both are 2 mod 3
case 2.a) if 128 is one number, note that 128+256=384 which is too large
so we must have 128 and 16; 328 - (128+16) = 184 rejected
case 2.b) 8 must be one of the numbers
8+16+64 is too small
8+256+64 = 328 and this is the only solution
Back to (x,y,z), as powers of 2,4,8 our three numbers can be arranged
(8,256,64), (64,256,8), (256,64,8) corresponding to xyz triplets:
(3,4,2)
(6,4,1)
(8,3,1)
----
But writing the program took maybe 1/20 the time
for x in range(9):
for y in range(5):
for z in range(3):
if 2**x+4**y+8**z == 328:
print('({},{},{})'.format(x,y,z) )
(3,4,2)
(6,4,1)
(8,3,1)
|
Posted by Larry
on 2023-12-10 10:18:17 |