Question: Imagine a game where you're given a starting number and can repeatedly make one of two moves. * You can either divide the number by

Imagine a game where you're given a starting number and can repeatedly make one of two moves.

* You can either divide the number by three if it's divisible by three, or subtract seven.

* You win the game if you can reduce the number to 1.

* For example, you can win with 15 because you can subtract 7 twice

* (you would also be allowed to divide 15 by 3, but that doesn't work for 15)

* You can win with 3 because you can divide by 3. You can win with 10 because you can

* subtract 7 and divide it by 3.

* You can't win with 5 or 6

* Write a function that returns if the game can be won with a particular starting number.

* @param startingNumber

* @return true if you can win the numbers game, false otherwise

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!