We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 838c7c9 commit 38d459cCopy full SHA for 38d459c
maths/collatz_sequence.py
@@ -4,6 +4,9 @@ def collatz_sequence(n):
4
if the previous term is even, the next term is one half the previous term.
5
If the previous term is odd, the next term is 3 times the previous term plus 1.
6
The conjecture states the sequence will always reach 1 regaardess of starting n.
7
+ Example:
8
+ >>> collatz_sequence(43)
9
+ [43, 130, 65, 196, 98, 49, 148, 74, 37, 112, 56, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]
10
"""
11
sequence = [n]
12
while n != 1:
0 commit comments