Sum of Divisors of n Excluding n || Python
In this we are going to see a basic program to find sum of 'n' numbers excluding 'n' in Python Programming Language.



def sum_factors(n):
    sum = 0
    # Return the sum of all factors of n, not including n
    i = 1
    while i < n:
        if n % i == 0:
            sum += i
        i += 1
    return sum

def main():
    num = int(input("Enter a number to find the sum of its factors: "))
    print("Sum = ", sum_factors(num))

main()

# Coded by Shreya Idate


#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post