fix: replace deprecated fractions.gcd with math.gcd (#7845)
## Bug
`fractions.gcd` was deprecated in Python 3.5 and removed in Python 3.9.
This causes an `AttributeError` on Python 3.9+.
## Fix
Replaced `fractions.gcd` with `math.gcd` which is the standard
replacement.