Accenture Coding Question | Sum Of Divisor | CodeWindow

Sum of divisors

Print the sum of the divisors of the integer number N.

Input specification:
Input 1: The integer ‘n’.

Output Specification:
Return the sum of divisors of ‘n’.

Example 1:
Input 1: 6

Output: 12
Explanation:
Divisors of 6 are 1,2,3,6. Sum of number (1+2+3+6)=12

Example 2:
Input 1: 36

Output: 91
Explanation:
Divisors of 36 are 1,2,3,4,6,9,12,18,36. Sum of number (1+2+3+4+6+9+12+18+36)=12

Solution in Python 3:

#https://codewindow.in
#join our telegram channel

n=int(input())
count=0
for i in range(1,n+1):
    if n%i==0:
        count=count+i
    else:
        pass
print(count)

# Telegram @codewindow

Output:

36
91
6
12
Recent Posts

Leave a Comment

Your email address will not be published. Required fields are marked *