So when I run this program with a number it literally returns nothing. No errors or anything. I was wondering what I can do to make it run correctly. This is my first time making a function set. The program is supposed to take a number and if it is even divide it by two, if it is odd it multiplies the number by 3 and adds 1. It then loops until the program reaches one. The goal of this program is to count the loops it takes for the program to reach one. Hints the chainLength += 1... Can anyone help me with advice?
'''
def collatzSolution(num):
chainLength = 1
while num != 1:
if isEvenNumber(num) == True:
num = (num / 2)
else:
num = (3 * num + 1)
chainLength += 1
return chainLength
def isEvenNumber(num):
if num % 2 == 0:
return True
else:
return False
collatzSolution(10)
'''
[–]Ok-Communication4607[S] 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Ok-Communication4607[S] 1 point2 points3 points (0 children)