Bonus Practice Problems(Deficient Number)

A number is said to be a deficient number if the sum of the proper divisors are less than that number. All divisors  of a number other than 1 and itself,   are called proper divisors. 8 is a deficient number since the sum of the proper divisors are 6 (proper divisors of 8 are 2 and 4) Examples of deficient numbers include 2, 3, 4, 5, 7, 8, 9, 10, 11, 13, 14, 15, 16, 17, 19, 21, 22, and 23. Given a number, write an algorithm and the subsequent Python code to check whether the given number is deficient or not.
Input format
Number to be checked
Output Format
Print Deficient or Not deficient
Input:
Number to be checked

Processing:
n = int(input())
div = []
for i in range(2,n):
    if n%i==0:
        div.append(i)
if sum(div) < n:
    print('Deficient')
else:
    print('Not deficient')

Output:
Print Deficient or Not deficient

Program:
n = int(input())
div = []
for i in range(2,n):
    if n%i==0:
        div.append(i)
if sum(div) < n:
    print('Deficient')
else:
    print('Not deficient')


Pseuodocode:
Step1.Get the number
Step2. find the proper divisors of the numbers and then store these numbers in div list
Step3. check if the sum of all the elements in div is less than the number if yes the print deficient else print Not deficient

Step4.End

No comments:

Post a Comment

Bonus Practice Problems(GMT To IST)

IST (Indian Standard Time) is 5 hours 30 minutes ahead of GMT(Greenwich Mean Time). Develop an algorithm and write the Python code to find...