Given 2 integers L and R, the task is to find out the number of integers in the range [L, R] such that they are completely divisible by their Euler totient value.
Input: L = 2, R = 3
(2) = 2 => 2 % (2) = 0
(3) = 2 => 3 % (3) = 1
Hence 2 satisfies the condition.
Input: L = 12, R = 21
Only 12, 16 and 18 satisfy the condition.
Approach: We know that the euler totient function of a number is given as follows:
Rearranging the terms, we get:
If we take a close look at the RHS, we observe that only 2 and 3 are the primes that satisfy n % = 0. This is because for primes p1 = 2 and p2 = 3, p1 – 1 = 1 and p2 – 1 = 2. Hence, only numbers of the form 2p3q where p >= 1 and q >= 0 need to be counted while lying in the range [L, R].
Below is the implementation of the above approach:
- Probability of Euler's Totient Function in a range [L, R] to be divisible by M
- Count of elements having Euler's Totient value one less than itself
- Euler's Totient Function
- Euler's Totient function for all numbers smaller than or equal to n
- Optimized Euler Totient Function for Multiple Evaluations
- Check if Euler Totient Function is same for a given number and twice of that number
- Queries to count integers in a range [L, R] such that their digit sum is prime and divisible by K
- Count pairs from 1 to N such that their Sum is divisible by their XOR
- Count of pairs in a given range with sum of their product and sum equal to their concatenated number
- Number of integers in a range [L, R] which are divisible by exactly K of it's digits
- Count integers in the range [A, B] that are not divisible by C and D
- Possible values of Q such that, for any value of R, their product is equal to X times their sum
- Count of integers in a range which have even number of odd digits and odd number of even digits
- Count numbers in range 1 to N which are divisible by X but not by Y
- Count of numbers in range which are divisible by M and have digit D at odd places
- Count of numbers in a range that does not contain the digit M and which is divisible by M.
- Ways to form an array having integers in given range such that total sum is divisible by 2
- Sum of product of all integers upto N with their count of divisors
- Find permutation of n which is divisible by 3 but not divisible by 6
- Count pairs of numbers from 1 to N with Product divisible by their Sum
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.