Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Better challenge

Name: Anonymous 2011-02-09 11:54

Prove that this program terminates for all positive values of n.


def sequence(n):
  while n != 1:
    print n,
    if n%2 == 0:        # n is even
      n = n/2
    else:               # n is odd
      n = n*3+1

Name: Anonymous 2011-02-10 8:34

The function is never called so the program always terminates successfully as per the Python standard.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List