Python Forum
How to get all divisors from a number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get all divisors from a number
#1
Hi people ,

I have what I presume is a really easy question but I cant get my mind wrapped around it..
How do I get a program to give me all divisors of a positive whole integer in a sorted list?
I have used a while loop with  while *number* % 2 == 0:
but I am really confused as to what to put in the if statement...

thanks..
Doesnotcompute
Reply
#2
Show us your code.
Reply
#3
There are so many solutions already there, see google:
http://stackoverflow.com/questions/17176...f-a-number
Reply
#4
Keep it nice and simple: divisors = lambda x: [i for i in range(2, x) if x%i==0]
Reply


Forum Jump:

User Panel Messages

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