Emil Bialobrzeski (12/10/2014)
i saw lots of people on social sites having problems with:
1+1+1+1+1+1+1+1+1+1+1+1x0+1 = ?
most of the answers was 1. So saying Simple may apply differently to others :hehe:
Slightly unfair question, though, because the answer depends on operator precedence. For instance, I was never taught at school that multiplication takes priority over addition, and if you just process that statement left to right, then the answer *is* 1--you add a load of 1s together, multiply that by zero, and add 1 to the result.
Wow, really? Proper order of operations is fairly important in most high level maths. I remember having drills wherein we had to take math expressions and add parentheses to show how the statement should be parsed.
Order of operations is an arbitrary syntax decision, and not necessarily implemented consistently in programming languages. Yes there is a standard in mathematics but it could easily have been different. It could have been that there was no decision at all and that the only way to guarantee order was with parentheses. Luckily parentheses are given priority, at least in every language I've come across. Doesn't hurt to add them in anyway, otherwise questions like that are just syntax memory tests rather than logic tests.
back to the real topic. I enjoyed the question. I suppose that depending on the underlying implementation, it could save a little memory 🙂