Given a positive integer n. Find whether a number is a semiprime or not. Print True if number is semiprime else False. A semiprime is a natural number that is a product of two prime numbers.
Input: 6 Output: True Explanation 6 is a semiprime number as it is a product of two prime numbers 2 and 3. Input: 9 Output: True Input: 8 Output: False
The approach is simple, factorize the given number by dividing it with the divisor of a number to remove the composite number. Meanwhile keep updating the count variable of prime number.
Time complexity: O()
Auxiliary space: O(1)
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Check if a number is divisible by all prime divisors of another number
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Program to check whether a number is Proth number or not
- Check if a number with even number of digits is palindrome or not
- Check if the number is a Prime power number
- Check whether given number N is a Moran Number or not
- Check if a number is Flavius Number
- Check if a number is Triperfect Number
- Check if a number is an Achilles number or not
- Check if a number is a Krishnamurthy Number or not
- Check if a number is a Trojan Number
- Check if a number is an Unusual Number or not
- Check if a number is a power of another number
- Check if a given number is factorial of any number
- Check if a number is a Mystery Number
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.
Improved By : vt_m