This program takes an integer input from the user and finds all the divisors of that number. Then it adds all the divisors and returns the sum of all the divisors as output. First, the program takes an integer input from the user and initializes a list with 1 as its first element, because 1 is always a divisor of any number.
Then it loops through all the numbers from 2 to (num-1) and checks whether they are divisors of the input number or not. If any number is a divisor, it adds that number to the list. Finally, it calculates the sum of all the elements in the list using the built-in sum() function and prints the result as the sum of all the divisors of the input number.
num = int(input("Enter the Number :")) div = [1] for i in range(2, num): if (num % i)==0: div.append(i) print("Sum of All Divisors :",sum(div))
Enter the Number :12 Sum of All Divisors : 16
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions