FastPrepFastPrep
Problem Brief

Counting Game

OA

The counting game is a widely popular casual game. Every participant in the game must count numbers in sequence. However, if the next number to be called is a multiple of 7, or if the next number contains the digit 7, then that number must be skipped, otherwise, you lose the game.

Rose and Zack play this game and find it too easy, so they decide to modify some rules: for any number containing the digit 7, all its multiples cannot be called either!

For example, if Rose calls out 6, since 7 cannot be called, Zack must call 8 next. If Rose calls out 33, since 34 is 17 times 2 and 35 is 7 times 5, Zack's next possible call is 36. If Rose calls out 69, because numbers 70 to 79 all contain the digit 7, Zack's next call must be 80.

Input Format

Input a line which contains a positive integer x, indicating the number called by Rose this time.

Output Format

Output a line which contains an integer. If the number called by Rose this time is invalid (cannot be called), output -1. Otherwise, output the number that Zack should call next.

1Example 1

Input
x = 6
Output
8
Explanation
Since 7 cannot be called, Zack must call 8 next.

2Example 2

Input
x = 33
Output
36
Explanation
Since 34 is 17 times 2 and 35 is 7 times 5, Zack's next possible call is 36.

3Example 3

Input
x = 300
Output
-1
Explanation
The number called by Rose this time is invalid (cannot be called), so the output is -1.
public int[] changeSegmentColors(String[] operations) {
  // write your code here
}
Input

x

6

Output

8

Sign in to submit your solution.