Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions maths/collatz_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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__":
Expand Down