Fix code style

This commit is contained in:
daniele 2023-06-07 22:06:22 +02:00
parent f827fd5dd6
commit cc90c8aa0c
Signed by: fuxino
GPG Key ID: 981A2B2A3BBF5514

View File

@ -71,8 +71,7 @@ def lcmm(values, n):
return lcm(value, lcmm(values[1:], n-1)) return lcm(value, lcmm(values[1:], n-1))
# Function implementing the Sieve or Eratosthenes to generate # Function implementing the Sieve or Eratosthenes to generate primes up to a certain number.
# primes up to a certain number.
def sieve(n): def sieve(n):
primes = [1] * n primes = [1] * n
@ -148,8 +147,7 @@ def sum_of_divisors(n):
for i in range(2, limit): for i in range(2, limit):
if n % i == 0: if n % i == 0:
sum_ = sum_ + i sum_ = sum_ + i
# If n is a perfect square, i=limit is a divisor and # If n is a perfect square, i=limit is a divisor and has to be counted only once.
# has to be counted only once.
if n != i * i: if n != i * i:
sum_ = sum_ + n // i sum_ = sum_ + n // i
@ -369,8 +367,7 @@ def phi(n, primes):
if n % 2 != 0: if n % 2 != 0:
break break
# If 3 is a factor of n, multiply the current ph by 1-1/3, # If 3 is a factor of n, multiply the current ph by 1-1/3, then divide all factors 3.
# then divide all factors 3.
if n % 3 == 0: if n % 3 == 0:
ph = ph * (1 - 1 / 3) ph = ph * (1 - 1 / 3)