-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hi Sebastian,
Thanks a lot for your research!
For find_element.py I found that there is a built-in function (for Python 3.9+) to calculate the least common multiple:
import math
def lcm():
return math.lcm(42, 43)And since Python 3.5 you can calculate the least common multiple using the greatest common divisor:
def lcm_gcd():
x = 42
y = 43
return abs(x * y) // math.gcd(x, y)So the previous fastest result (generator) and these implementations have the following timings on my machine with Python 3.10.4:
python -m timeit -s "from find_element import generator" "generator()"
5000 loops, best of 5: 84.4 usec per loop
python -m timeit -s "from find_element import lcm_gcd" "lcm_gcd()"
1000000 loops, best of 5: 254 nsec per loop
python -m timeit -s "from find_element import lcm" "lcm()"
1000000 loops, best of 5: 205 nsec per loopMetadata
Metadata
Assignees
Labels
No labels