Ctrl K

Remainder-One Whiteboard

Easy
A whiteboard shows a single number start. Each round goes like this: for every number x already on the board, find all numbers i from 1 to start with x % i == 1, and write them on the board. Numbers are never erased, and a number already present is not written again. A billion rounds pass. How many distinct numbers are on the board at the end?
Example 1
start=6 → 5

6 leaves remainder 1 when divided by 5, so 5 is written. 5 leaves remainder 1 for 2 and 4. 4 leaves remainder 1 for 3. The board holds 6, 5, 4, 3, 2: five numbers.

Example 2
start=2 → 1

No divisor works for 2 (2 % 1 = 0, 2 % 2 = 0), so the board keeps a single number.

Constraints
  • 1 ≤ start ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Lost Ticket EasyEven Piles of Cards EasyOdd Counters After the Presses EasyNoughts and Crosses Verdict EasyPairs of Equal Values Easy
loading Python…
Input
start=6
Expected
5

Run checks the first 3 tests in your browser. Submit checks all 52 tests on the server, hidden ones included.