GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Sum of factors of a given numbers .

Sum of Factors  I tried many times ...but get TLE . Please help me to solve this.......

asked Dec 17, 2016 by rashedcs

To me question is not clear, if input is say 12 then ans should be 1+2+4+3+6+12=28 or 2+2+3 = 7 (only prime factors).

1 Answer

n=int(input())
l=[]
for i in range(n):
    k=int(input())
    l.append(k)

for s in l:
    c=0
    for i in range(1,s+1):
        if(s%i==0):
                c=c+i
    print(c)

answered Dec 20, 2016 by JeevanRao
...