All 16.Only one?
I'm not picking what part of the number gets distributed, the division operator does.
The division operator has ownership of 2 parts of a statement, something that exists before it (the numerator), and something that exists after it (the denominator).
Everything before the / is "8"
Everything after it is "2(2+2)"
Is there anything in the before that has rules or properties that supersede the division operator? No, so the numerator is 8.
Is there anything in the after part that has rules or properties that supersede the division operator? Yes, so the denominator requires evaluation before proceeding with the division calculation.
What in the denominator requires evaluation? We have parenthesis and the distributive property. So you must evaluate "2(2+2)" and use it as the denominator.
Yeah? Try to code that in Java and see what happens. What comes after is not all implied to be the denominator.
Java has an awesome math library.Java (programmers) is capable of doing math?
Java has an awesome math library.
It's no FORTRAN 77, sir! No, sir! It is NOT.
Hey, COBOL can still crunch some numbers now!
Real programmers coded in binary.
I remember what COBOL stands for. FORTRAN was the first language I was exposed to though, and I don't remember what it stood for. I just remember being confused a lot. We had dumb terminals for FORTRAN, so we didn't do the actual card punching ourselves. I remember having to wait until the next day to find out the compile results though.You are old if you remember what the acronyms COBOL and FORTRAN represent.
You are very old if you remember doing bubble sorts on your 80 column card decks.
I remember what COBOL stands for. FORTRAN was the first language I was exposed to though, and I don't remember what it stood for. I just remember being confused a lot. We had dumb terminals for FORTRAN, so we didn't do the actual card punching ourselves. I remember having to wait until the next day to find out the compile results though.
Formula Translation.
Yeah? Try to code that in Java and see what happens. What comes after is not all implied to be the denominator.
Of course not, 2 is not a legitimate function name. The same as (8/2)(2+2) wouldn't be valid syntax. The question isn't if a multiplication operator is required somewhere, the question is where exactly it takes place.
If I have a statement of "(2X+2X)" and need to factor out the X, what are you going to write
- X(2+2)
- X*(2+2)
If I have a statement of "(2X+2Y)" and need to factor out the 2, what are you going to write
- 2(X+Y)
- 2*(X+Y)
If I have a statement of "(X/2 + Y/2)" and factor out the 1/2, which one are you most likely going to write
- (X+Y)/2
- 1/2*(X+Y)
- (1/2)(X+Y)
- 1/2(X+Y)
I would hope no one would say #4. If the original statement was written like any of the first 3, I'd agree the answer is 16. The issue is that in the original statement, there isn't a multiplication operator or a 2nd set of parenthesis. Lacking those, we know that a number preceding parenthesis is a value that has been factored out and has to be reapplied to the contents of the parenthesis by the distribution property. We can shortcut it any way that makes it as simpler for us (solve contents first, then distribute, distribute then solve contents), but the issue is what is the factor to distribute, "8/2", or "2"? For people who say 16 is the answer, then they believe that the equation is one of
- 8(2+2)/2
- (2*8 + 2*8)/2
- 8/2*(2+2)
- (2*8/2 + 2*8/2)
- (8/2)(2+2)
- (2(8/2) + 2(8/2))
But why are we assuming that it is the whole fraction that must be distributed? Why wouldn't you just take the number immediately preceding the grouping?
Let's add more to the statement, what if it was
9/3/8/2(2+2)
Would you be using 3/16ths as the factor for the grouping?
This is why I only see the 2 as the factor to the grouping, you can't go gobbling up operators preceding the parenthesis to use as the factor, because where does the fraction stop? The 8? The 3? All the way to the 9? Maybe it's just me, but it doesn't make much sense to go grabbing more than the number.
The only way you can solve something is if there is an equal sign in it, and there is not, so you are evaluating this expression.
Where does the fraction stop? If youÂ’re writing it inline like that it stops after the first number. When I calculate that by hand I get 0.75. In excel the same. In java I might write the above as the following snipet:
...
final float x = 9f/3/8/2*(2+2);
assert x==.75;
...
If you run that it wonÂ’t throw an assertion error because x == .75. So java agrees with me and excel.
You wouldnÂ’t distribute the 2 because itÂ’s all one term after the contents of the parentheses are evaluated. It doesnÂ’t matter if you leave off the * when writing it, because itÂ’s implied. In java you have to include it explicitly. Also, in java, you have to specify float here or it will assume integers, hence the 9f.
(function() {
function jamil() {
// evaluate 9 / 3 / 8 / 2 ( 2 + 2 )
// compute left to right just using multiply
var x = 9;
x /= 3;
x /= 8;
x /= 2;
x *= (2 + 2);
console.log("Jamil says the answer is " + x);
return x;
}
function danimal() {
// evaluate 9 / 3 / 8 / 2 ( 2 + 2 )
// distribute 1st available number pre-parenthesis, then compute
var x = (2*2 + 2*2);
var y = 9;
y /= 3;
y /= 8;
y /= x;
console.log("Danimal says the answer is " + y);
return y;
}
jamil();
danimal();
})();