Javatpoint Logo
Javatpoint Logo

Program to determine whether a given number is a Deficient number

The deficient number can be defined as the number for which the sum of the proper divisors is lesser than the number itself.

For example, the number 21 with its proper divisors (1, 3 and 7) has sum (11) lesser than itself.

Algorithm

MAIN

  • STEP 1: START
  • STEP2: Enter n
  • STEP 3: if Def(n) is true then
    print "yes"
    else
    print "no"
  • STEP 4: END

Def(n)

  • STEP 1: START
  • STEP 2: set i = divsum(n)
  • STEP 3: if i <2n
    then return true
    else
    return false
  • STEP 3: END

divsum(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: RETURN sum
  • STEP 6: END

Java Program

Output:

Enter the number? 23
The number is deficient.

C Program

Output:

Enter the number? 21
The number is deficient.

Python Program

Output:

Enter the number? 45
The number is deficient.

C# Program

Output:

Enter the number? 45
The number is deficient.

PHP Program

Output:

Enter the number? 45
The number is deficient.
Next Topic#





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA