First few Blum Integers are 21, 33, 57, 69, 77, 93, 129, 133, 141, 161, 177, …
Note: Because of the condition that both the factors should be semi-primes, even numbers can not be Blum integers neither can be the numbers below 20,
So we have to check only for an odd integer greater than 20 that if it is a Blum Integer or not.
Input: 33 Output: Yes Explanation: 33 = 3 * 11, 3 and 11 are both semi-primes as well as of the form 4t + 3 for t = 0, 2 Input: 77 Output: Yes Explanation: 77 = 7 * 11, 7 and 11 both are semi-prime as well as of the form 4t + 3 for t = 1, 2 Input: 25 Output: No Explanation: 25 = 5*5, 5 and 5 are both semi-prime but are not of the form 4t + 3, Hence 25 is not a Blum integer.
Approach: For a given odd integer greater than 20, we calculate the prime numbers from 1 to that odd integer. If we find any prime number that divides that odd integer and its quotient both are prime and follow the form 4t + 3 for some integer, then the given odd integer is Blum Integer.
Below is the implementation of above approach :
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Check if an integer can be expressed as a sum of two semi-primes
- Count pairs in Array whose product is a Kth power of any positive integer
- Length of longest increasing prime subsequence from a given array
- Minimize sum of prime numbers added to make an array non-decreasing
- Sum of all numbers up to N that are co-prime with N
- Count prime numbers that can be expressed as sum of consecutive prime numbers
- Length of longest common prime subsequence from two given arrays
- Minimum replacement of pairs by their LCM required to reduce given array to its LCM
- Product of all numbers up to N that are co-prime with N
- Check if all array elements are pairwise co-prime or not
- Length of longest subarray having only K distinct Prime Numbers
- Smallest composite number not divisible by first N prime numbers
- Count of subarrays consisting of only prime numbers
- Minimize Array length by repeatedly replacing co-prime pairs with 1
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.