Python Forum
Listing the factors of a number
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Listing the factors of a number
#2
You only need to check up to the square root of the number. But to do that, you need to append the factor you found (i (which is a bad variable name, use more descriptive names like 'factor' or 'possible')), and the number divided by the factor.

For example, checking factors of 16, you get 2 as a factor. You add that to the factors list, as well as 16 / 2 = 8.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Listing the factors of a number - by TitaniumGene - Jul-22-2018, 11:38 PM
RE: Listing the factors of a number - by ichabod801 - Jul-23-2018, 12:46 AM

Forum Jump:

User Panel Messages

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