Skip to content

Commit f08403a

Browse files
author
Mavis Cron
committed
fix: use yield from get_remaining_sequence to prevent duplicate values
1 parent 1b0cb48 commit f08403a

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

math/Collatz-Conjecture/Collatz-Conjecture.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@ def get_remaining_sequence(n: int) -> List[int]:
2323
def collatz_sequence(start: int) -> Generator[int, None, None]:
2424
"""Generate the Collatz sequence starting from the given number."""
2525
if start in steps_cache:
26-
n = start
27-
yield n
28-
while n != 1:
29-
n = collatz_next(n)
30-
yield n
26+
yield from get_remaining_sequence(start)
3127
return
3228

3329
n = start

0 commit comments

Comments
 (0)