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)
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 a number is divisible by all prime divisors of another number
- Check if a large number is divisible by a number which is a power of 2
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check if the number is a Prime power 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 if a number is a Mystery Number
- Check if a number is an Achilles number or not
- Check if a number is a power of another number
- Check if a number is Triperfect Number
- Check whether a given number N is a Nude Number or not
- Check whether given number N is a Moran Number or not
- Check if a number is an Unusual Number or not
- Check whether a given number is an ugly number or not
- Check if a number is a Trojan Number
- Check if a number is a Krishnamurthy Number or not
- How to check if a given number is Fibonacci number?
- Check if a given number is factorial of any number
- Check if given number is Emirp Number or not
- Check if a number starts with another 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