Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Math Problem

Math Problem

Scheduled Pinned Locked Moved The Lounge
help
25 Posts 19 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H hansoctantan

    hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

    S Offline
    S Offline
    snowman53
    wrote on last edited by
    #6

    Your interpretation is correct - type it into any spread sheet and you get 9. Not a "proof", but at least a demonstration of common acceptance.

    1 Reply Last reply
    0
    • H hansoctantan

      hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

      K Offline
      K Offline
      Kenneth Haugland
      wrote on last edited by
      #7

      I guess you have to be specific in you input, but I assume that this is what actuall happens: the compiler would see 6/2, no problem that is 3, then It sees a (), and thinks do the stuff inside, witch is 3, then multiply 3*3 = 9 If you wrote this: 6/(2*(2+1)) the story would be different.... My conclution came from here[^]. I know, shamless self promotion :-\

      1 Reply Last reply
      0
      • H hansoctantan

        hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #8

        www.wolframalpha.com/input/?i=6%2F2%281%2B2%29[^] PEMDAS is not supposed to be interpreted as "M before D" or "A before S". It could have been PEDMAS, PEMDSA or PEDMSA, but they're not as nice to pronounce.

        1 Reply Last reply
        0
        • H hansoctantan

          hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

          _ Offline
          _ Offline
          _beauw_
          wrote on last edited by
          #9

          I think you're mixing notation styles and the result is ambiguous. Are you showing us a computer expression or an algebra problem? If it's a computer expression, I would tend to think you really mean this: 6/2*(1+2) And in that case the answer is 9. If you're trying to use more customary mathematical notation, then I think you really mean this: 6 -------- 2 (1+2) And in this second case, the answer is 1. That big division bar I'm trying to draw above overrides PEDMAS (a.k.a "My Dear Aunt Sally"). The forward slash generally is not interpreted as being a big division bar... but in light of the confused-looking expression you presented, I wonder if that's what was meant.

          B 1 Reply Last reply
          0
          • H hansoctantan

            hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

            W Offline
            W Offline
            Wjousts
            wrote on last edited by
            #10

            I get 42. I always get 42. Weird...

            K H 2 Replies Last reply
            0
            • W Wjousts

              I get 42. I always get 42. Weird...

              K Offline
              K Offline
              Kenneth Haugland
              wrote on last edited by
              #11

              Did you type in "the Meaning of life"? :-D

              1 Reply Last reply
              0
              • H hansoctantan

                hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

                0 Offline
                0 Offline
                0bx
                wrote on last edited by
                #12

                That's a syntax problem, not a math problem.

                Giraffes are not real.

                1 Reply Last reply
                0
                • _ _beauw_

                  I think you're mixing notation styles and the result is ambiguous. Are you showing us a computer expression or an algebra problem? If it's a computer expression, I would tend to think you really mean this: 6/2*(1+2) And in that case the answer is 9. If you're trying to use more customary mathematical notation, then I think you really mean this: 6 -------- 2 (1+2) And in this second case, the answer is 1. That big division bar I'm trying to draw above overrides PEDMAS (a.k.a "My Dear Aunt Sally"). The forward slash generally is not interpreted as being a big division bar... but in light of the confused-looking expression you presented, I wonder if that's what was meant.

                  B Offline
                  B Offline
                  BillW33
                  wrote on last edited by
                  #13

                  In customary mathematical notation the multiplication sign is assumed and would be written out as 6/2*(1+2). Which will evaluate to 9. It can only be properly interpreted as another value if it is written as 6/(2*(1+2)) or equivently 6 -------- 2 * (1+2) A C, C++, C#, Java, etc. compiler will also evaluate this as 9.

                  Just because the code works, it doesn't mean that it is good code.

                  _ 1 Reply Last reply
                  0
                  • H hansoctantan

                    hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

                    Mike HankeyM Offline
                    Mike HankeyM Offline
                    Mike Hankey
                    wrote on last edited by
                    #14

                    You are right 9, mult. and div. take precedence.

                    VS2010/Atmel Studio 6.0 ToDo Manager Extension
                    Version 3.0 now available. There is no place like 127.0.0.1

                    1 Reply Last reply
                    0
                    • B BillW33

                      In customary mathematical notation the multiplication sign is assumed and would be written out as 6/2*(1+2). Which will evaluate to 9. It can only be properly interpreted as another value if it is written as 6/(2*(1+2)) or equivently 6 -------- 2 * (1+2) A C, C++, C#, Java, etc. compiler will also evaluate this as 9.

                      Just because the code works, it doesn't mean that it is good code.

                      _ Offline
                      _ Offline
                      _beauw_
                      wrote on last edited by
                      #15

                      I agree with that. If you forced me to choose an answer, I would choose 9.

                      1 Reply Last reply
                      0
                      • H hansoctantan

                        hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

                        P Offline
                        P Offline
                        Pete OHanlon
                        wrote on last edited by
                        #16

                        You might want to explain to him about BODMAS.

                        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                        1 Reply Last reply
                        0
                        • H hansoctantan

                          hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

                          Z Offline
                          Z Offline
                          ZurdoDev
                          wrote on last edited by
                          #17

                          9 is right. Parens first and then left to right.

                          There are only 10 types of people in the world, those who understand binary and those who don't.

                          1 Reply Last reply
                          0
                          • H hansoctantan

                            hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

                            A Offline
                            A Offline
                            AspDotNetDev
                            wrote on last edited by
                            #18

                            Please Excuse My Dear Aunt Sally = PEMDAS = Parentheses, Exponents, (Multiply or Divide), (Add or Subtract) = PE(M|D)(A|S) Your friend is either thinking that parens are an operation or that all multiplies occur before divides. Placing a number next to parens creates an implicit multiplication. So, your equation becomes:

                            6 / 2 * (1 + 2)

                            And multiplications and divisions are of equal precedence, so they occur left to right in the order they appear. First, parens:

                            6 / 2 * 3

                            Next, all multiplications and divisions in order:

                            3 * 3
                            9

                            It is not true that all multiplications occur before all divisions. The answer is 9.

                            Thou mewling ill-breeding pignut!

                            1 Reply Last reply
                            0
                            • H hansoctantan

                              hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

                              S Offline
                              S Offline
                              SoMad
                              wrote on last edited by
                              #19

                              It looks like you got a good reaction to this question and since there are already several answers, I will not go into that. I think the really important question is, what are you intending to do? If you are coding this (obviously using variables, function calls or other goodies), do you want the "9 result" or the "1 result"? When coding something like this, I prefer to put in additional parenthesis even when they are not needed due to the precedence of operators. I feel that separating the terms like that is the best way to avoid confusion when other developers have to work on the code. (6/2)*(1+2) (or 6/(2*(1+2)) if that is your intention) might look like it is written by a noob, but everyone understands the meaning and can agree on the result. Adding spaces before and after the operators also helps the readability. Soren Madsen

                              1 Reply Last reply
                              0
                              • H hansoctantan

                                hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

                                V Offline
                                V Offline
                                virang_21
                                wrote on last edited by
                                #20

                                //No animal was harmed during execution of this program.
                                static void Main(string[] args)
                                {
                                int result = 6 / 2 * (1 + 2);
                                Console.WriteLine("Math Problem 6 / 2 * (1 + 2) = {0}", result); // Answer = 9
                                Console.ReadKey();

                                }

                                Edit : The Answer can be 6 as well.. ( If you are doing yoga or you are a spiderman and looking at the screen upside down ) :)

                                Zen and the art of software maintenance : rm -rf * Math is like love : a simple idea but it can get complicated.

                                1 Reply Last reply
                                0
                                • T Tim Groven

                                  I was always under the belief that multiplication and division were on the same level in the order of operations, so you do them in the order they appear.

                                  K Offline
                                  K Offline
                                  krumia
                                  wrote on last edited by
                                  #21

                                  The precedence is BODMAS Brackets, Of, Division, Multiplication, Addition, Substraction.

                                  1 Reply Last reply
                                  0
                                  • H hansoctantan

                                    hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

                                    J Offline
                                    J Offline
                                    Joan M
                                    wrote on last edited by
                                    #22

                                    9, appearence is the boss when same weight operations.

                                    [www.tamautomation.com] Robots, CNC and PLC machines for grinding and polishing.

                                    1 Reply Last reply
                                    0
                                    • H hansoctantan

                                      hey guys... :-D :-D :-D We have a slight debate about this... 6/2(1+2) so whats the answer.. My answer is 9 6/2=3 1+2=3 3*3=9 My friends answer is 1 He did this(his saying he follow this PEMDAS) 6/2(1+2) = 6/2*3 = 6/6 <<==== this is what he write/do answer 1

                                      M Offline
                                      M Offline
                                      Mark_Wallace
                                      wrote on last edited by
                                      #23

                                      erm, multiplying by the denominator might not be the method approved of in most text books. 6/2*3 = 18/2

                                      I wanna be a eunuchs developer! Pass me a bread knife!

                                      1 Reply Last reply
                                      0
                                      • W Wjousts

                                        I get 42. I always get 42. Weird...

                                        H Offline
                                        H Offline
                                        hansoctantan
                                        wrote on last edited by
                                        #24

                                        Well how did you do it???:confused::confused::confused:

                                        P 1 Reply Last reply
                                        0
                                        • H hansoctantan

                                          Well how did you do it???:confused::confused::confused:

                                          P Offline
                                          P Offline
                                          Pete OHanlon
                                          wrote on last edited by
                                          #25

                                          It's an insider joke taken from The Hitchhikers Guide To The Galaxy which states the ultimate answer to life, the universe, everything is 42. The problem is, no one knows what the question is.

                                          *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                          CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups