Problem:
Return true if the given non-negative number is a multiple of 3 or a multiple of 5. Use the % "mod" operator -- see Introduction to Mod
or35(3) → true
or35(10) → true
or35(8) → false
Solution:
public boolean or35(int n) { return (n % 3 == 0) || (n % 5 == 0); }
thx
ReplyDeleteJust learned ternary lol
ReplyDeletepublic boolean or35(int n) {
boolean or = (n%3==0 || n%5==0) ? true : false;
return or;
}