Count Distinct Numbers on Board

You are given a positive integer n, that is initially placed on a board. Every day, for 10^9 days, you perform the following procedure:

  • For each number x present on the board, find all numbers 1 <= i <= n such that x % i == 1.
  • Then, place those numbers on the board.

Return the number of distinct integers present on the board after 10^9 days have elapsed.

Note:

  • Once a number is placed on the board, it will remain on it until the end.
  • % stands for the modulo operation. For example, 14 % 3 is 2.
Example 1
Inputn = 5
Output4
At the end of a billion days, the distinct numbers on the board will be 2, 3, 4, and 5.
Example 2
Inputn = 3
Output2
After a billion days, the only two distinct numbers on the board are 2 and 3.

Constraints

  • 1 <= n <= 100

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate