Skip to content

Commit 38d459c

Browse files
authored
doctest
1 parent 838c7c9 commit 38d459c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

maths/collatz_sequence.py

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ def collatz_sequence(n):
44
if the previous term is even, the next term is one half the previous term.
55
If the previous term is odd, the next term is 3 times the previous term plus 1.
66
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]
710
"""
811
sequence = [n]
912
while n != 1:

0 commit comments

Comments
 (0)