Compound Boolean Expressions

AP Computer Science A· difficulty 3/5

For "x is divisible by 3 OR by 5":

  • A

    x % 3 == 0 && x % 5 == 0

  • B

    x % 3 == 0 || x % 5 == 0

    check_circle
  • C

    x % 15 == 0

  • D

    x / 3 == 0 || x / 5 == 0

Explanation

OR satisfies "either or both"; FizzBuzz pattern.

Want 10 more like this — adaptive to your weak spots?

Related questions