Coding Collatz Conjecture
Channel: Vincent Gaudeo lie
Date: 2020-11-19

Sorry about the silly variable error in the code! You can skip from 12:00 to 17:20 if you don't really want to see the error. 
Read more about what am I trying to do at: https://en.wikipedia.org/wiki/Collatz_conjecture
In this video, I'm just trying to code a collatz sequence. Not really trying to prove anything about the collatz conjecture. Just trying to make a simple code for graphing collatz conjecture. 
Sorry for the bad English! It's one of the first times that I am trying to explain my code.
Feel Free to give me suggestion about what to code in the comment!
Dont Forget To Subscribe and Like the video!
I use Jupyter Notebook by Anaconda to make the code. This is the full code if you want to: 
from matplotlib import pyplot as plt
import time
start=time.time()
arr=[]
arr2=[]
lowerBound=1
upperBound= 10**5 # ** = ^ 10^3=1000
for n in range(lowerBound,upperBound):
    x=n
    steps=0
    while True:
        if x%2==0: 
            x=int(x/2)
            steps+=1 
        elif x==1:
            print("steps: "+str(steps))
            break
        else:
            x=3*x+1
            steps+=1
    arr.append(steps)
    arr2.append(n)
plt.plot(arr2,arr)
plt.show()
maxValue=str(max(arr))
print("Max steps needed: " + maxValue)
print("Max integer that needs most steps: " + str(arr.index(int(maxValue))+lowerBound))
end=time.time()
print("execution time: " + str(round((end-start),2))+ " seconds")