refactor: Move constants outside of variable scope (#7262)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Dhruv Manilawala <dhruvmanila@gmail.com> Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
@@ -33,13 +33,13 @@ def continuous_fraction_period(n: int) -> int:
|
||||
"""
|
||||
numerator = 0.0
|
||||
denominator = 1.0
|
||||
ROOT = int(sqrt(n)) # noqa: N806
|
||||
integer_part = ROOT
|
||||
root = int(sqrt(n))
|
||||
integer_part = root
|
||||
period = 0
|
||||
while integer_part != 2 * ROOT:
|
||||
while integer_part != 2 * root:
|
||||
numerator = denominator * integer_part - numerator
|
||||
denominator = (n - numerator**2) / denominator
|
||||
integer_part = int((ROOT + numerator) / denominator)
|
||||
integer_part = int((root + numerator) / denominator)
|
||||
period += 1
|
||||
return period
|
||||
|
||||
|
||||
Reference in New Issue
Block a user