Skip to content

Commit bc52aa6

Browse files
ArjunwadkarAjaycclauss
authored andcommitted
Some grammatical and spelling corrections (TheAlgorithms#1475)
1 parent a57809a commit bc52aa6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

maths/collatz_sequence.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
def collatz_sequence(n):
22
"""
3-
Collatz conjecture: start with any positive integer n.Next termis obtained from the previous term as follows:
4-
if the previous term is even, the next term is one half the previous term.
3+
Collatz conjecture: start with any positive integer n.Next term is obtained from the previous term as follows:
4+
if the previous term is even, the next term is one half of the previous term.
55
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.
6+
The conjecture states the sequence will always reach 1 regaardless of starting value n.
77
Example:
88
>>> collatz_sequence(43)
99
[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]
1010
"""
1111
sequence = [n]
1212
while n != 1:
13-
if n % 2 == 0: # even
13+
if n % 2 == 0: # even number condition
1414
n //= 2
1515
else:
1616
n = 3 * n + 1

0 commit comments

Comments
 (0)