Count Bi-Prime Numbers in Range
In various cryptographic and number theory applications, numbers with specific prime factorizations play a crucial role. For instance, numbers that are products of exactly two distinct primes are often used in generating public keys or for specific hashing algorithms due to their unique properties and the computational difficulty of factoring large numbers. This problem challenges you to identify and count such "bi-prime" numbers within a given integer range.
Your task is to implement a function that takes two integers, L and R, representing a closed range [L, R], and returns the total count of bi-prime numbers within this range. A bi-prime number is defined as a positive integer that is the product of exactly two distinct prime numbers.
L: An integer representing the lower bound of the range (inclusive).R: An integer representing the upper bound of the range (inclusive).[L, R].[L, R] is inclusive, meaning both L and R can be bi-prime numbers and should be counted if they are.Examples
Example 1
Input:
L = 1, R = 20
Output:
4
Note:
The bi-prime numbers in [1, 20] are: 6 (23), 10 (25), 14 (27), and 15 (35).
Example 2
Input:
L = 20, R = 30
Output:
3
Note:
The bi-prime numbers in [20, 30] are: 21 (37), 22 (211), and 26 (2*13).
Example 3
Input:
L = 4, R = 5
Output:
0
Note:
Neither 4 (2*2) nor 5 (a prime number) is a bi-prime number.
Constraints
1 <= L <= R <= 10^9L and R will always be valid integers within the specified range.R up to 10^9.L and R are bi-primes.Loading editor...