curriculum/challenges/english/blocks/daily-coding-challenges-python/6925e2068081f40f549ced1c.md
Given a positive integer, return the sum of all its divisors.
0).For example, given 6, return 12 because the divisors of 6 are 1, 2, 3, and 6, and the sum of those is 12.
sum_divisors(6) should return 12.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_divisors(6), 12)`)
}})
sum_divisors(13) should return 14.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_divisors(13), 14)`)
}})
sum_divisors(28) should return 56.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_divisors(28), 56)`)
}})
sum_divisors(84) should return 224.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_divisors(84), 224)`)
}})
sum_divisors(549) should return 806.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_divisors(549), 806)`)
}})
sum_divisors(9348) should return 23520.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertEqual(sum_divisors(9348), 23520)`)
}})
def sum_divisors(n):
return n
def sum_divisors(n):
total = 0
for i in range(1, n + 1):
if n % i == 0:
total += i
return total