Answer the question
In order to leave comments, you need to log in
Write a condition that is true?
Write a condition that is true when:
- only one of the numbers X, Y and Z is a multiple of five
I only thought of ((X%5 ==0) ^ (Y%5 ==0)) ^ (Z%5 = = 0)
Also, there is a condition, do not use more than 3 comparison operators
Answer the question
In order to leave comments, you need to log in
Consider an expression of the form
If X is a multiple of 5, then the value of the expression will be 1*2*3*4 = 24, otherwise it will be 0, because one of the factors will be equal to 0.
Given these considerations, the solution will be the following expression
(((X + 1) % 5) * ((X + 2) % 5) * ((X + 3) % 5) * ((X + 4) % 5) +
((Y + 1) % 5) * ((Y + 2) % 5) * ((Y + 3) % 5) * ((Y + 4) % 5) +
((Z + 1) % 5) * ((Z + 2) % 5) * ((Z + 3) % 5) * ((Z + 4) % 5)
) == 24
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question