194k views
5 votes
We'll say a number is special if it is a multiple of 11 or if it is one more than a multiple of 11. Return true if the given non-negative number is special. Use the % "mod" operator -- see Introduction to Mod

A specialEleven(22) → true
B specialEleven(23) → true
C specialEleven(24) → false

User Jabrena
by
8.4k points

1 Answer

3 votes

Final answer:

A number is special if it is a multiple of 11 or one more than a multiple of 11. We can determine this by using the % operator.

Step-by-step explanation:

A number is considered special if it is a multiple of 11 or if it is one more than a multiple of 11. To determine if a given non-negative number is special, we can use the % (mod) operator. If the number % 11 is equal to 0 or 1, then the number is special and we return true. Otherwise, we return false.

For example, if we take the number 22, 22 % 11 equals 0, so it is a multiple of 11 and therefore special. On the other hand, if we take the number 24, 24 % 11 equals 2, which is neither 0 nor 1, so it is not special and we return false.

User Neel Basu
by
7.9k points