FastPrepCounting Game
Problems/Counting Game

Counting Game

Trend Micro logoTrend Micro● MediumOA

Updated Sep 2026

QuestionFunctionExamples

Problem statement

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.

Function

getNextNumber(x: int) → int

Examples

Example 1

x = 6return = 8

Since 7 cannot be called, Zack must call 8 next.

Example 2

x = 33return = 36

Since 34 is 17 times 2 and 35 is 7 times 5, Zack's next possible call is 36.

Example 3

x = 300return = -1

Since 300 is a multiple of 75, which contains the digit 7, it cannot be called. Therefore, the output is -1.

More Trend Micro interview questions

  • Change Segment ColorsOA · Seen Dec 2024
  • Find SequencesOA · Seen Aug 2024

Similar questions at other companies

  • Capping Portfolio WeightsCapstone Investment Advisors · OA
  • Bold Play to Reach a GoalSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Repeated Mirror XORMathWorks · OAMathWorks interview questions
  • Stacked Item and Category DiscountsPalantir · OAPalantir interview questions
  • Find Total CostJP Morgan Chase · OAJP Morgan Chase interview questions
  • Macaron Order PriceOpenAI · OAOpenAI interview questions
  • Daily Settlement for Long and Short PositionsBelvedere Trading · OA
  • Last Object Exit TimeIBM · OAIBM interview questions
  • Debug the Risk-Limit QuoterMillennium · OAMillennium interview questions
  • Prime Factor VisitationMaven Securities · OAMaven Securities interview questions
All Trend Micro interview questionsSee Trend Micro hiring insights
Saved
class Solution {
    public int getNextNumber(int x) {
      // write your code here
    }

}
Checking account…