MCPcopy Index your code
hub / github.com/geekcomputers/Python / sequence

Function sequence

Collatz-Conjecture.py:63–75  ·  view source on GitHub ↗

The core part of this program, it performs the operations of the Collatz sequence to the given number (parameter number).

(number: float)

Source from the content-addressed store, hash-verified

61 print("\nBEGIN COLLATZ SEQUENCE")
62
63 def sequence(number: float) -> float:
64 """
65 The core part of this program,
66 it performs the operations of
67 the Collatz sequence to the given
68 number (parameter number).
69 """
70 modulo = number % 2 # The number modulo'd by 2
71 if modulo == 0: # If the result is 0,
72 number = number / 2 # divide it by 2
73 else: # Otherwise,
74 number = 3 * number + 1 # multiply by 3 and add 1 (3x + 1)
75 return number
76
77 # Execute the sequence
78 while True:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected