Python Forum
I need help to solve this task using while statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help to solve this task using while statement
#6
try this

def sum_divisors(n):
    sum=1
    x=int(n**0.5)
    for i in range(2,(x//1)+1):
        if n%i==0:
            sum=sum+i
        if n%i==0 and n/i!=i:
            sum=sum+(n/i)            
    return int(sum)
Reply


Messages In This Thread
RE: I need help to solve this task using while statement - by Jaikanth - Apr-01-2020, 08:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Stuck with using lists to solve task gery576 9 1,042 Jan-16-2024, 06:29 PM
Last Post: DPaul
  How to solve this task? DERO 2 1,875 Dec-06-2021, 07:15 PM
Last Post: BashBedlam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020