Math and Comparison Operators Comments

Comments

  • I solved this problem with first declaring sum and mul as integers. Then returning their values using modulus.

  • the question confused me, when did i have to multiply at any point???

  • @Ryan, the product of a and b means multiply a by b. Would this be clearer:

    Multiply a by b and then get the remainder from dividing that product by the sum of a and b ?

  • Yeah, thank you. The product made me think addition but i guess that would be the sum. Maybe i should have taken more math classes lol. So far this has been the best teaching program i have used

    cont...
  • Excellent tutorial thus far. It is probably hard to understand the precise syntax that is needed to pose the problems.

  • i was so confused by the wording of product. to me it processed as the same thing as sum :/

  • Gandalf the Fabulous approves of this.

  • Bilbo Swaggins likes this

  • I read the challenge about 5 times and operated exactly what they wrote: return (a*b)%(a+b);

    I hope this helps. Wording can be tricky but it's all going back to basic math terminology.

  • The remainder of 5 % 3 could have been -1 too.

  • This one tripped me too. It can be done this way as well:
    int product = a * b;
    int sum = a + b;
    return product % sum;

  • PEMDAS is also known as BEDMAS (brackets instead of parentheses)

  • I am a math teacher so this wasnt to hard for me :-)

  • I have a question... I understand that you can just return the value of "(a * b) % (a + b);" ... But I also tried doing this one by assigning to value to a new variable, int C. I added an int

    cont...
  • i got confused, i got it when i read the question again.

  • Good way of learning..

  • that's really awsome man

  • My solutions was like ArtTric

  • I don't know where to input int product = a*b;
    Int sum = a+b;

  • I got it correct after 3 tries. I may be wrong but I surmise that '%'is to be put between code that identifies what variables you are working with such as 'sum' and really means: "divide and also give me the remainder".

  • something is wrong here because how is 5*1 divided by (5+1) have a remainder of 5?

    basic math says its .8 with a remainder of 2. so 5*1 is 5. well 5 divided by 6 equals 0.8 r2

  • I get the code, but it has a flaw because 5*1 divided by 6 does not have a remainder of 5. its 2

    because basic math says that 5/6 is 0.8 with a remainder of 2.

  • guys i did this
    //int num
    //(1*5)%(6);
    return (a*b)%(a+b)

  • int mul = a * b;
    int sum = a+b;
    int result = mul%sum;
    return result;

  • What is going on in this solution:
    Applying the rules for Math and Operator Order of Precedence
    1. addition is performed first because of ( )
    2. multiplication is the next operation

    cont...
Contact Us
Sign in or email us at [email protected]