From 37d5fff4ea60aa0b002bcecaa0861fb5df2441a0 Mon Sep 17 00:00:00 2001 From: Hugo Folloni Date: Wed, 6 Oct 2021 13:44:39 -0300 Subject: [PATCH] Input for user choose his Collatz sequence Now the user can tell the algorithm what number he wants to run on the Collatz Sequence. --- maths/collatz_sequence.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/maths/collatz_sequence.py b/maths/collatz_sequence.py index 7b3636de69f4..a7ff857e1132 100644 --- a/maths/collatz_sequence.py +++ b/maths/collatz_sequence.py @@ -7,7 +7,6 @@ def collatz_sequence(n: int) -> list[int]: obtained as follows: If n term is even, the next term is: n / 2 . If n is odd, the next term is: 3 * n + 1. - The conjecture states the sequence will always reach 1 for any starting value n. Example: >>> collatz_sequence(2.1) @@ -34,10 +33,10 @@ def collatz_sequence(n: int) -> list[int]: def main(): - n = 43 + n = int(input("Your number: ")) sequence = collatz_sequence(n) print(sequence) - print(f"collatz sequence from {n} took {len(sequence)} steps.") + print(f"Collatz sequence from {n} took {len(sequence)} steps.") if __name__ == "__main__":