I am trying to display the 3x+1 problem (if the number is odd multiply it by 3 and add 1, if it is even divide by 2) live on a line graph. How can I take the outputs that are still generating and plot them on a graph in real time?
This is the code I wrote:
from random import randint
random_int = (randint(1, 100))
i = 1
while i == 1:
if random_int % 2 == 0:
random_int = random_int/2
print(random_int)
else:
random_int = random_int*3+1
print(random_int)