diophantine equation with 3 variables

Randyyy

Junior Member
Joined
May 14, 2020
Messages
113
Hey, the problem is as follows:
As hungry child walks into a store where the cost of a gum is $0.5, a snickers is $4, and a cola is $9. The child buys a few of each sort adding up to a total of 34 items for the exact cost of $97. How many of each did he get?
My attempt:
0.5x+4y+9z=97 since we only deal with integers I multiply by 2:
x+8y+18z=194, I also know that x+y+z=34 hence x=34-y-z. I plug that into my diophantine equation.
7y+17z=160, Solving with Euclid's Algorithm I eventually stumble upon y0=5 and z0=-2.
This gives me (y,z)=(160*y0+17n,160*z0-7n).
I plug it into x=34-y-z and get x=-446-10n. But how do I now solve for actual values of x,y,z?
 
[MATH]7y+17z = 160[/MATH]
[MATH]160 \equiv 7 \text{ mod } 17 \implies 7 + 17z = 160 \implies z=9, \, y = 1, \, x = 24[/MATH]
I'd pick another store ...
 
Agreed, very expensive. Seems like I had done my calculations correct, I only needed to solve the inequality of {x,y,z}>0 and you find the 2 integer solutions.

Thanks for the input! :)
 
Top