Closed kvinwang closed 3 years ago
Reminder: Converted plugin spirograph.py
does not require import math
or import fractions
Add: lcm/gcd
into bmath
:
from bmath import (cos, lcm, pi, sin)
No dependency on standard libraries (fractions/math) and no py version dependency!
Example:
bmath.py
add:
# -----------------------------------------------------------------------------
# Delta is wise, dinosaurs must die! (I hope, nofx will forgive me ;)
# -----------------------------------------------------------------------------
def gcd(a, b):
"""Return greatest common divisor using Euclid's algorithm."""
while b:
a,b = b,a%b
return a
# -----------------------------------------------------------------------------
# floor is sufficient? I want to see something/someone sticking to the ceiling,
# preferably, my closest friend, linoleum!
# -----------------------------------------------------------------------------
def lcm(a, b):
"""Return lowest common multiple."""
return (a*b) // gcd(a,b)
spirograph.py
change:
from bmath import (cos, lcm, pi, sin)
spirograph.py
required lcm
, which in turn, required gcd
, both have been accounted for now in bmath
Solves the issue, although, there is more to the code! (comments are optional)