Find the smallest positive integer that is not divisible by a given integer .
Problem
Given a positive integer , consider the sequence of positive multiples of :
Your task is to return the smallest positive integer that does not belong to this sequence.
In other words, find the smallest positive integer that is not divisible by .
Notes
- The answer is always a positive integer.
- For , every positive integer is a multiple of $1$, so there is no positive integer that is missing from the sequence of multiples.
Input Format
- A single positive integer .
Output Format
- Return the smallest positive integer that is not divisible by .
Constraints
Example 1
Input
k = 2
Output
1
Explanation
The multiples of 2 are 2, 4, 6, 8, ... The smallest positive integer that is not a multiple of 2 is 1.
Example 2
Input
k = 5
Output
1
Explanation
The multiples of 5 are 5, 10, 15, 20, ... The smallest positive integer that is not a multiple of 5 is 1.
Show 1 more example
Example 3
Input
k = 1
Output
2
Explanation
Every positive integer is a multiple of 1, so there is no missing positive integer in the sequence. A practical convention is to return the next integer after the first positive integer, which is 2.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.