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:
Caeden
2022-10-16 10:33:29 +01:00
committed by GitHub
parent 7776411621
commit c6582b35bf
17 changed files with 107 additions and 97 deletions

View File

@@ -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