Given an integer N, the task is to find the minimum possible integer X such that X % M = 1 for all M from the range [2, N]
Input: N = 5
61 % 2 = 1
61 % 3 = 1
61 % 4 = 1
61 % 5 = 1
Input: N = 2
Approach: Find the lcm of all the integers from the range [2, N] and store it in a variable lcm. Now we know that lcm is the smallest number which is divisible by all the elements from the range [2, N] and to make it leave a remainder of 1 on every division, just add 1 to it i.e. lcm + 1 is the required answer.
Below is the implementation of the above approach:
- Largest number by which given 3 numbers should be divided such that they leaves same remainder
- Minimum positive integer divisible by C and is not in range [A, B]
- Minimum number of operations on a binary string such that it gives 10^A as remainder when divided by 10^B
- Biggest integer which has maximum digit sum in range from 1 to n
- Maximum positive integer divisible by C and is in the range [A, B]
- Find an integer X which is divisor of all except exactly one element in an array
- Smallest integer > 1 which divides every element of the given array
- Sum of (maximum element - minimum element) for all the subsets of an array.
- Minimum positive integer value possible of X for given A and B in X = P*A + Q*B
- Minimum numbers needed to express every integer below N as a sum
- Minimum positive integer to divide a number such that the result is an odd
- Find the minimum sum of distance to A and B from any integer point in a ring of size N
- Find the minimum positive integer such that it is divisible by A and sum of its digits is equal to B
- All possible co-prime distinct element pairs within a range [L, R]
- Replace the maximum element in the array by coefficient of range
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.