Program to determine whether a given number is an abundant number

The abundant number can be called as an excessive number and defined as the number for which the sum of its proper divisors is greater than the number itself.

A first abundant number is the integer 12 having the sum (16) of its proper divisors (1, 2, 3, 4, 6) which is greater than itself (12).

Examples: 12, 18, 20, 24, 30, 36

In this program, we have to check whether a given number is an abundant number using the algorithm given below.

Algorithm

MAIN

  • STEP 1: START
  • STEP 2: ENTER n.
  • STEP 3: if CheckAbundant(n) is true
    then PRINT "yes"
    else
    PRINT "no".

CheckAbundant (n)

  • STEP 1: START
  • STEP 2: SET i= GetSum(n)
  • STEP 3: if i>n
    then RETURN true
    else
    RETURN false.

GetSum(n)

  • STEP 1: START
  • STEP 2: SET sum = 0
  • STEP 3: REPEAT STEP 4 UNTIL i<=?n
  • STEP 4: if n%i == 0
    then
    if(n/i==i)
    sum=sum+i
    else
    sum =sum+i
    sum= sum+n/i
  • STEP 5: sum =sum - n
  • STEP 6: RETURN sum

Java program

Output:

Enter the number?
20
The number is Abundant

C program

Output:

Enter the number? 34
The number is not Abundant.

Python Program:

Output:

Enter the number?24
The number is Abundant.

C# program

Output:

Enter the number?
67
The number is not Abundant.

PHP Program

Output:

Enter the number? 56
The number is Abundant.
Next Topic#




Latest Courses