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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started