In number theory, a semiperfect number or pseudoperfect number is a natural number n that is equal to the sum of all or some of its proper divisors. A semiperfect number that is equal to the sum of all its proper divisors is a perfect number.
Given a number, the task is to check if the number is a semi-perfect number or not.
Output: The number is Semiperfect
Output: The number is not Semiperfect
The first few semiperfect numbers are
6, 12, 18, 20, 24, 28, 30, 36, 40
Approach: Store all th factors of the number in a data-structure(Vector or Arrays). Sort them in increasing order. Once the factors are stored, Dynamic programming can be used to check if any combination forms N or not. The problem becomes similar to the Subset Sum Problem. We can use the same approach and check if the number is a semi-perfect number or not.
Below is the implementation of the above approach.
Time Complexity: O(number of factors * N)
Auxiliary Space: O(number of factors * N)
- Super Ugly Number (Number whose prime factors are in given set)
- Number of ways to represent a number as sum of k fibonacci numbers
- Represent a number as a sum of maximum possible number of Prime Numbers
- Program to check whether a number is Proth number or not
- Minimum number of squares whose sum equals to given number n
- Check if a number is an Unusual Number or not
- Check if a number is an Achilles number or not
- k-Rough Number or k-Jagged Number
- Number of divisors of a given number N which are divisible by K
- Check whether a number is Non-hypotenuse number
- Check if the given number is Ore number or not
- Entringer Number
- Number of NGEs to the right
- Thabit number
- Hilbert 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.