Advertisement

All Jokes aside, what is 6/2(1+2)?

Started by March 27, 2015 12:00 AM
115 comments, last by BaneTrapper 9 years, 9 months ago

But that question is intentionally ambiguous so I think people fallback to whatever they were taught: traditional order of operations or the PEMDAS rule.

Don't you mean, the BEDMAS rule? tongue.png

Which I might add produces the "correct" answer:

6/2(1+2) = 6/2(3) = 3(3) = 9

Interesting. I voted 9 but my calculator says 1 for 6/2(1+2) without the multiplication sign. It's 9 for 6/2*(1+2). Didn't even know it made a difference.

Advertisement

Wow, this is reminding me of the dress issue. But this is math! It is very concise. How is it left to interpretation?

Because the problem is all about syntax (and there are many of those) and nothing about semantics. It's not a math problem, just a besserwisser quiz.

[edit]

Oh, didn't realize there where hundreds of answers in this topic, with many "proofs" of the true grammar of language. rolleyes.gif

openwar - the real-time tactical war-game platform

For the late-comers to the thread, try read through it :)

I think we already covered everything regarding different syntax conventions, BEDMAS/PEMDAS and the pitfalls if you just try to follow it without understanding it, the logic behind the operator ordering (its not just a convention, even though the syntax is), and more...

I just found some interesting information in a book called "How to Think Like a Computer Scientist" that talks about order of operations for Python.

  • Parentheses have the highest precedence and can be used to force an expression to evaluate in the order you want. Since expressions in paren- theses are evaluated first, 2 * (3-1) is 4, and (1+1)**(5-2) is 8. You can also use parentheses to make an expression easier to read, as in (minute * 100) / 60, even though it doesn’t change the result.

  • Exponentiation has the next highest precedence, so 2**1+1 is 3 and not 4, and 3*1**3 is 3 and not 27.

  • Multiplication and Division have the same precedence, which is higher than Addition and Subtraction, which also have the same precedence. So 2*3-1 yields 5 rather than 4, and 2/3-1 is -1, not 1 (remember that in integer division, 2/3=0).

  • Operators with the same precedence are evaluated from left to right. So in the expression minute*100/60, the multiplication happens first, yielding 5900/60, which in turn yields 98. If the operations had been evaluated from right to left, the result would have been 59*1, which is 59, which is wrong.

They call me the Tutorial Doctor.

As far as I know there is no “interesting” information there. Everything there is standard 3rd-grade math (save that exponents came in 4th grade).
Except “integer division”. In school we had to figure out the remainders. But as far as the order of operations go…


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Advertisement

Got rekt so hard, i blame that i am tired unsure.png

This topic is closed to new replies.

Advertisement