Given a number , find the number of distinct integers obtained by lcm(X, N)/X where X can be any positive number.
Input: N = 2 Output: 2 if X is 1, then lcm(1, 2)/1 is 2/1=2. if X is 2, then lcm(2, 2)/2 is 2/2=1. For any X greater than 2 we cannot obtain a distinct integer. Input: N = 3 Output: 2
It is known that lcm(x, y) = x*y/gcd(x, y).
lcm(X, N) = X*N/gcd(X, N) or, lcm(X, N)/X = N/gcd(X, N)
So only the distinct factors of can be the distinct integers possible. Hence count the number of distinct factors of N including 1 and N itself, which is the required answer.
Below is the implementation of the above approach:
Time Complexity: O(sqrt(n))
- Total distinct pairs from two arrays such that second number can be obtained by inverting bits of first
- Count of integers obtained by replacing ? in the given string that give remainder 5 when divided by 13
- Check whether a number can be represented as sum of K distinct positive integers
- Maximum number of distinct positive integers that can be used to represent N
- Sum of two numbers if the original ratio and new ratio obtained by adding a given number to each number is given
- Median in a stream of integers (running integers)
- Mode in a stream of integers (running integers)
- Lexicographically smallest permutation of size A having B integers exceeding all preceeding integers
- Integers from the range that are composed of a single distinct digit
- Check if the sum of distinct digits of two integers are equal
- Generate permutation of 1 to N such that absolute difference of consecutive numbers give K distinct integers
- Represent (2 / N) as the sum of three distinct positive integers of the form (1 / m)
- Find distinct integers for a triplet with given product
- Find any K distinct odd integers such that their sum is equal to N
- Find K distinct positive odd integers with sum N
- Find N distinct integers with zero sum
- Find N distinct integers with sum N
- Find the final number obtained after performing the given operation
- Find a number K having sum of numbers obtained by repeated removal of last digit of K is N
- Number of Co-prime pairs obtained from the sum of digits of elements in the given 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 email@example.com. 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.