Abundant number In Python

           

        Abundant number In Python


An abundant number is a number for which the sum of its proper divisors is greater than the

 number itself.

The divisors of 12 are 1, 2, 3, 4 and 6.

The sum of divisors of 12 is 16.

12 < 16.Hence, 12 is an abundant number.

Program:

    n = int(input("Enter N Value"))
    sum = 0
    for i in range(1,n):
    if(n % i == 0):
    sum = sum + i
    if(n < sum):
    print("It is a Abundant Number")
    else:
    print("Not Abundant Number")

    OutPut:
    Enter N Value12
    It is a Abundant Number

    Enter N Value4
    Not Abundant Number

















    No comments:

    Post a Comment