Collatz Conjecture of Congruent Modulo M
Description:
Collatz Conjecture Explained
The Collatz Conjecture is a mathematical hypothesis that applies to positive integers. It states that if you start with any positive integer n
, the following sequence will always eventually reach 1:
- If
n
is even, divide it by 2. - If
n
is odd, multiply it by 3 and add 1.
This process is repeated iteratively, with each number in the sequence being halved if even or tripled and incremented by 1 if odd, until the sequence eventually reaches 1. See the wiki page.
Collatz Sequence of Congruent Modulo M.
We can apply this same proccess for integers of Modulo M, there is the formula for Collatz Sequence of Modulo M that will be applied repeatealy:
Your objective is create a function collatz_module(m)
that will return tuple with two values (value_verification_array, is_conjecture_true_at_M)
where value_verification_array
is a array of 0
to m-1
which the element of value_verification_array[n]
is true
if n
eventually reaches 1 and false
if it loops or go to 0.
The is_conjecture_true_at_M
is a boolean, true
if every n
bigger than 0 in the value_verification_array[n]
is true
otherwise is false
.
Function Signature:
def collatz_module(m):
"""
Generates a tuple containing Analysis of Collatz Conjecture of Congruent Modulo M.
Parameters:
m (int): Number which the sequence will be congruent.
Returns:
tuple: A tuple containing two values:
- value_verification_array (list)
- is_conjecture_true_at_M (bool)
"""
return ([], False)
Input:
'm' (2 ≤ m ≤ 80000) - Number which the sequence will be congruent.
Output:
Must return tuple with two values (value_verification_array, is_conjecture_true_at_M)
.
Example:
print(collatz_module(4)) # M=4, Outputs: ([False, True, True, True], True)
print(collatz_module(5)) # M=5, Outputs: ([False, True, True, False, True], False)
print(collatz_module(6)) # M=6, Outputs: ([False, True, True, True, True, True], True)
print(collatz_module(7)) # M=7, Outputs: ([False, True, True, False, True, True, False], False)
Notes
- The
n=0
will be alwaysfalse
andn=1
will be alwaystrue
by the definitions, so you must ignore in theis_conjecture_true_at_M
verification.
Similar Kata:
Stats:
Created | May 12, 2024 |
Published | May 12, 2024 |
Warriors Trained | 98 |
Total Skips | 43 |
Total Code Submissions | 110 |
Total Times Completed | 18 |
Python Completions | 18 |
Total Stars | 4 |
% of votes with a positive feedback rating | 73% of 11 |
Total "Very Satisfied" Votes | 6 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 11 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 4 kyu |
Lowest Assessed Rank | 6 kyu |