Python Forum
Multiplying between two values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiplying between two values
#6
There are so few numbers that brute force is still pretty efficient. Since you cannot iterate with floats I just multiply everything times 10 and test every number from 1 (0.1x10) to 100 (10x10) to see if it is a factor of 100.
factors = [x/10 for x in range(1, 101) if (100 / x) % 1 == 0]
print(factors)
For a larger range you can speed thing up by only testing numbers from 0.1 to the square root of the value and using these to compute the "upper" factors.
Reply


Messages In This Thread
Multiplying between two values - by doug2019 - Oct-19-2020, 10:14 PM
RE: Multiplying between two values - by bowlofred - Oct-19-2020, 10:21 PM
RE: Multiplying between two values - by jefsummers - Oct-19-2020, 11:14 PM
RE: Multiplying between two values - by doug2019 - Oct-19-2020, 11:17 PM
RE: Multiplying between two values - by bowlofred - Oct-19-2020, 11:31 PM
RE: Multiplying between two values - by deanhystad - Oct-20-2020, 04:42 AM
RE: Multiplying between two values - by DeaD_EyE - Oct-20-2020, 08:03 AM
RE: Multiplying between two values - by doug2019 - Oct-20-2020, 05:49 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  List structure lost when multiplying Protonn 2 2,306 Apr-23-2020, 04:16 AM
Last Post: buran
  multiplying elements in a list Olavv 3 3,483 Feb-27-2020, 04:55 PM
Last Post: DeaD_EyE
  Multiplying two lists to make an array pberrett 15 6,002 May-15-2019, 02:22 AM
Last Post: micseydel

Forum Jump:

User Panel Messages

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