Problem Statement
One day, nClassmates classmates decided to play an exciting game. They formed a circle and assigned themselves player numbers from 0 to nClassmates - 1 in a clockwise direction. Then, they counted from 1 to nTimes, inclusive, starting with player 0 and going in a clockwise direction. Each player spoke out the current number, and then, his clockwise neighbor spoke out the next number, etc. If a player got a number that was divisible by 3, he would cry out the word "hello" instead of speaking out the number. Return the number of times that player who cried out "hello".
Definition
- Class:
- ExcitingGame
- Method:
- howMany
- Parameters:
- int, int, int
- Returns:
- int
- Method signature:
- int howMany(int nClassmates, int nTimes, int who)
- (be sure your method is public)
Constraints
- nClassmates will be between 1 and 1000, inclusive.
- nTimes will be between 1 and 10000, inclusive.
- who will be between 0 and nClassmates - 1, inclusive.
Examples
2
13
0
Returns: 2
Player 0 cried out "hello" for the numbers 3 and 9.10
10
1
Returns: 0
Player 1 only had one turn, and he spoke out the number 2.3
30
2
Returns: 10
He cried out "hello" on all of his turns.895
8544
837
Returns: 3