Skip to content

Commit b7f1f39

Browse files
author
thotaDeepika
committed
Fix ruff linting errors
1 parent 257a3ed commit b7f1f39

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

quantum/shors_algorithm.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ def is_prime(n: int) -> bool:
7575
return True
7676
if n % 2 == 0:
7777
return False
78-
for i in range(3, int(math.sqrt(n)) + 1, 2):
79-
if n % i == 0:
80-
return False
81-
return True
78+
return all(n % i != 0 for i in range(3, int(math.sqrt(n)) + 1, 2))
8279

8380

8481
def is_perfect_power(n: int) -> tuple[int, int] | None:
@@ -463,7 +460,7 @@ def factor_with_explanation(n: int) -> None:
463460
print(" - Successfully found factors!")
464461
print()
465462
print("=" * 60)
466-
print(f"RESULT: {n} = {factors[0]} × {factors[1]}")
463+
print(f"RESULT: {n} = {factors[0]} * {factors[1]}")
467464
print("=" * 60)
468465
else:
469466
print(" - Failed to find factors")
@@ -491,7 +488,7 @@ def factor_with_explanation(n: int) -> None:
491488
result = shors_algorithm(num)
492489
if result:
493490
p, q = result
494-
print(f"{num:4d} = {p} × {q}")
491+
print(f"{num:4d} = {p} * {q}")
495492
else:
496493
print(f"{num:4d} = Failed to factor")
497494

0 commit comments

Comments
 (0)