Math and Comparison Operators Comments
Comments
-
the question confused me, when did i have to multiply at any point???
-
@Ryan, the product of
a
andb
means multiplya
byb
. Would this be clearer:
Multiplya
byb
and then get the remainder from dividing that product by the sum ofa
andb
? -
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
online. Some of the ?'s are somewhat difficult but thats what learning is about. Thank you for the email and reply.
-
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
C in public static int, and set the equation equal to C, returned C, but the code didn't work. How would I store its value to a new variable?
-
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".
-
yeeyee
-
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- modulus is the last operation performed before returning the results
solution:
return ( a * b % ( a + b )); -
it can be also done by this:
int product = a+b;
return (a*b)%product;
// product is the sum of A and B, i could have named it anything//
Jay Learn
Jul 23, 1:23 AMI solved this problem with first declaring sum and mul as integers. Then returning their values using modulus.