Skip to content

Commit d88cb32

Browse files
Add solution for Problem 810
1 parent aa30a0b commit d88cb32

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

project_euler/problem_810/sol1.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,26 +61,26 @@ def divisors(num: int) -> set[int]:
6161
return s
6262

6363

64-
def mobius_table(n: int) -> list[int]:
64+
def mobius_table(num: int) -> list[int]:
6565
"""
66-
Generate a variant of Möbius function values from 1 to n.
66+
Generate a variant of Möbius function values from 1 to num.
6767
6868
>>> mobius_table(10)[:6]
6969
[0, 1, -1, -1, 0, -1]
7070
"""
71-
mob = [1] * (n + 1)
72-
is_prime = [True] * (n + 1)
71+
mob = [1] * (num + 1)
72+
is_prime = [True] * (num + 1)
7373
mob[0] = 0
7474

75-
for p in range(2, n + 1):
75+
for p in range(2, num + 1):
7676
if is_prime[p]:
7777
mob[p] = -1
78-
for j in range(2 * p, n + 1, p):
78+
for j in range(2 * p, num + 1, p):
7979
is_prime[j] = False
8080
mob[j] *= -1
8181
p2 = p * p
82-
if p2 <= n:
83-
for j in range(p2, n + 1, p2):
82+
if p2 <= num:
83+
for j in range(p2, num + 1, p2):
8484
mob[j] = 0
8585
return mob
8686

0 commit comments

Comments
 (0)