Hi, so im writting a Python program, and ive hit a spot of bother
"TypeError: unsupported operand type(s) for %: 'list' and 'int'"
if n is 1 the sequence ends
if n is even the next n of the sequence = n/2
if n is odd then the next n of the sequence = (3*n)+1
def hailstone(num): length = 1 while num != 1: print num, "===>>", if num % 2 != 0: num = 3 * num + 1 else: num = num / 2 length = length + 1 print num, print ("; length = %d") % length return length() print hailstone(range(0,100))
I am trying to get the code to print out the first 100 values with their lengths!
All help is appreciated! thanks