Given two positive integers L and R, the task is to count the elements from the range [L, R] whose prime factors are only 2 and 3.
Input: L = 1, R = 10
2 = 2
3 = 3
4 = 2 * 2
6 = 2 * 3
8 = 2 * 2 * 2
9 = 3 * 3
Input: L = 100, R = 200
Approach: Start a loop from L to R and for every element num:
- While num is divisible by 2, divide it by 2.
- While num is divisible by 3, divide it by 3.
- If num = 1 then increment the count as num has only 2 and 3 as its prime factors.
Print the count in the end.
Below is the implementation of the above approach:
- Count numbers in a range having GCD of powers of prime factors equal to 1
- K-Primes (Numbers with k prime factors) in a range
- Count common prime factors of two numbers
- Numbers in range [L, R] such that the count of their divisors is both even and prime
- Common prime factors of two numbers
- Sort an array according to the increasing count of distinct Prime Factors
- Number of distinct prime factors of first n natural numbers
- Number which has the maximum number of distinct prime factors in the range M to N
- Sum of all the prime numbers in a given range
- Prime numbers in a given range using STL | Set 2
- Print prime numbers in a given range using C++ STL
- Sum of all prime divisors of all the numbers in range L-R
- Find the highest occurring digit in prime numbers in a range
- Count Odd and Even numbers in a range from L to R
- Find count of Almost Prime numbers from 1 to N