Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Dec 1, 2023
1 parent 6e0ea79 commit 81d7dfb
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/galois/_prime.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,15 @@ def prev_prime(n: int) -> int:
if n <= MAX_N:
return PRIMES[bisect.bisect_right(PRIMES, n) - 1]

shifts = [29, 23, 19, 17, 13, 11, 7, 1] # Factorization wheel for basis {2, 3, 5}
base = n // 30 * 30 # Wheel factorization starting point
found = False # Success flag
shifts = [29, 23, 19, 17, 13, 11, 7, 1] # Factorization wheel for basis {2, 3, 5}
base = n // 30 * 30 # Wheel factorization starting point
found = False # Success flag

while not found:
for shift in shifts:
i = base + shift # May be bigger than n

i = base + shift # May be bigger than n
if i >= n:
continue

if is_prime(i):
found = True
break
Expand Down Expand Up @@ -219,17 +217,15 @@ def next_prime(n: int) -> int:
if n < PRIMES[-1]:
return PRIMES[bisect.bisect_right(PRIMES, n)]

shifts = [1, 7, 11, 13, 17, 19, 23, 29] # Factorization wheel for basis {2, 3, 5}
base = n // 30 * 30 # Wheel factorization starting point. May be less than n.
found = False # Success flag
shifts = [1, 7, 11, 13, 17, 19, 23, 29] # Factorization wheel for basis {2, 3, 5}
base = n // 30 * 30 # Wheel factorization starting point. May be less than n.
found = False # Success flag

while not found:
for shift in shifts:
i = base + shift

if i <= n:
continue

if is_prime(i):
found = True
break
Expand Down

0 comments on commit 81d7dfb

Please sign in to comment.