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)
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check if a number is divisible by all prime divisors of another number
- 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 whether the given number is Euclid Number or not
- Check if given number is Emirp Number or not
- Check if a number is Flavius Number
- Check if a number is a power of another number
- How to check if a given number is Fibonacci number?
- Check if a number is an Unusual Number or not
- Check if a number is a Mystery Number
- Check if a number is an Achilles number or not
- Check if a number is Triperfect Number
- Check Whether a number is Duck Number or not
- Check if a number is a Trojan 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 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.
Improved By : vt_m