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
- Check if a number with even number of digits is palindrome or not
- Program to check whether a number is Proth number or not
- Check Whether a number is Duck Number or not
- Check if a number is an Unusual Number or not
- Check if a number is a power of another number
- Check if given number is Emirp Number or not
- Check if a number is a Trojan Number
- How to check if a given number is Fibonacci number?
- Check if a number is an Achilles number or not
- Check if a number is a Mystery Number
- Check whether a number is Non-hypotenuse number
- Check whether the given number is Euclid Number or not
- Check if a number is a Krishnamurthy Number or not
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