How many ordered pairs (x, y) will satisfy the equation 2x + 3y = 100?
Answer: 17
The sum being 100 implies that x is less than or equal to 50 and y is less than 34 which accounts for the values in the loops below.
Solve using the following script:
for(var x=0; x<=50; x++){
for(var y=0; y<34; y++){
if(2*x+3*y==100){
console.log("x: "+x+" y: "+y);
}
}
}
Please take down this post
ReplyDelete-Calvin Lin
Brilliant Mathematics Challenge Master