Question 1038295
there's an easy way to solve this.
since the number of pigs has to be an integer, then look for all the factors of 145.
you get 1 * 147 or 5 * 29 and i think nothing else.
it can't be 1 and it can't be 5 so it has to be either 147 or 29.
i went for 29 and got good results.
with 29 pigs bought, the cost per pig is 5 dollars.
8 pigs died, so 21 pigs were sold at a profit of 2 dollars apiece.
this means they were sold for 7 dollar each.
total revenue was 21 * 7 = 147 dollars.
total profit was 2 dollars.
solution looks good.


i had a lot more trouble solving it algebraically.
i finally latched on to a method that provided the algebraic solution.


let x = the number of pigs.
let c - the cost per pig.


since the total cost is 145, you get x*c = 145.


8 pigs died, so there were 21 pigs left.
these were sold at a profit of 2 dollars apiece.
the total profit was 2 dollars.


you get (x-8) * (c+2) = 147


since the cost per pig was c, then the revenue per pig had to be c+2 in order to get a profit of 2 dollars per pig.


the number of pigs sold was x-8.


since the total profit was 2 dollars, then the total revenue had to be 147 dollars because the total cost was 145 dollars.


the two equations you have are:


x*c = 145
(x-8) * (c+2) = 147


in the first equation, solve for c to get c = 145/x.


in the second equation, replace c with 145/x to get:


(x-8) * (c+2) = 147 becomes (x-8) * (145/x + 2) = 147


simplify by performing the multiplication to get 145 + 2x - (8*145)/x - 16 = 147


subtract 145 and add 16 to both sides of the equation to get 2x - (8*145)/x = 18


multiply both sides of this equation by x to get 2x^2 - (8*145) = 18x


subtract 18x from both sides of this equation and simplify 8*145 to get 2x^2 - 18x - 1160 = 0


divide both sides of the equation by 2 to get x^2 - 9x - 580 = 0


factor this quadratic equation to get (x-29) * (x+20) = 0


solve for x to get x = 29 or x = -20.


since the number of pigs can't be negative, then x = -20 is no good and your only valid solution is x = 29.


when x = 29, the total cost per pig is 145/29 = 5 dollars.
a profit of 2 dollars per pig sold means each pig that was sold brought in 7 dollars.
21 * 7 = 147.
the total revenue was 147 and the total cost was 145 which made the total profit equal to 2 dollars.


the solution is confirmed to be good.