VOOZH about

URL: https://www.geeksforgeeks.org/dsa/primitive-abundant-number/

⇱ Primitive Abundant Number - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Primitive Abundant Number

Last Updated : 15 Jul, 2025

A number N is said to be Primitive Abundant Number if N is an Abundant number and all it's proper divisors are Deficient Numbers
The first few Primitive Abundant Numbers are:

20, 70, 88, 104, 272, 304......... 

Check if N is a Primitive Abundant Number


Given a number N, the task is to find if this number is Primitive Abundant Number or not. 
Examples:

Input: N = 20 
Output: YES 
Explanation:
Sum of 20's proper divisors is - 1 + 2 + 4 + 5 + 10 = 22 > 20, 
So, 20 is an abundant number. 
The proper divisors of 1, 2, 4, 5 and 10 are0, 1, 3, 1 and 8 respectively, 
Each of these numbers is a deficient number 
Therefore, 20 is a primitive abundant number.
Input: N = 17 
Output: No 



Approach:

  1. Check if the number is an Abundant number or not, i.e, sum of all the proper divisors of the number denoted by sum(N) is greater than the value of the number N
  2. If the number is not abundant then return false else do the following
  3. Check if all proper divisors of N are Deficient Numbers or not, i.e, sum of all the divisors of the number denoted by divisorsSum(n) is less than twice the value of the number N.
  4. If both above conditions are true print "Yes" else print "No.


Below is the implementation of the above approach:


Output
Yes

Time Complexity: O(N1/2)

Auxiliary Space: O(1)

Approach 2: Dynamic Programming:

  • In this approach, we use dynamic programming to memoize the results of whether a number is abundant or not. We first initialize a DP array dp with all elements set to -1 to indicate that we haven't computed the result for that number yet.
  • We then define a sum_of_divisors function that computes the sum of divisors of a given number. We use this function to check whether a number is abundant or not. If the result for a particular number n is already present in the DP array, we return that result directly. Otherwise, we compute the result using the sum_of_divisors function and store it in the DP array for future use.
  • Finally, we check if the given number is abundant or not using the is_abundant function and print "Yes" or "No" accordingly.

Here is the code below:

Output: 

Yes

Time Complexity: O(N log log N), where N is the input number.

Auxiliary Space: O(N), as we need to create an array of size N to store the sum of divisors for all numbers from 1 to N.

References:https://en.wikipedia.org/wiki/Primitive_abundant_number

Comment
Article Tags: