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 Whether a number is Duck Number or not
- Program to check whether a number is Proth number or not
- Check whether the given number is Euclid Number or not
- Check whether all the rotations of a given number is greater than or equal to the given number or not
- Check whether given number N is a Moran Number or not
- Check whether a given number N is a Nude Number or not
- Check whether a given number is an ugly number or not
- Check whether a number is circular prime or not
- Check whether a number has exactly three distinct factors or not
- Check whether a number is Emirpimes or not
- Check whether a given number is Polydivisible or Not
- C Program to Check Whether a Number is Prime or not
- Check whether a given Number is Power-Isolated or not
- Check whether the given number is Wagstaff prime or not
- Check whether a number has consecutive 0's in the given base or not
- Check whether N is a Dihedral Prime Number or not
- Check whether the binary equivalent of a number ends with "001" or not
- Check whether a large number is divisible by 53 or not
- Check whether a number is Good prime or not
- C Program to check whether a number is a Perfect Cube 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