SHARE
TWEET

Untitled

a guest Apr 20th, 2017 63 in 3 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def collatz():
  2.     global number
  3.     if number % 2 == 0:
  4.         print(number/2)
  5.         while True:
  6.             number = number/2
  7.             if int(number) == 1:
  8.                 print("You have now seen Collatz Conjecture in action.")
  9.                 break
  10.             else:
  11.                 print(number//2)
  12.                 continue
  13.        
  14.     elif number % 2 == 1:
  15.         print(3 * number + 1)
  16.         number = number * 3 + 1
  17.         collatz()
  18.                
  19.    
  20.        
  21.  
  22. print("Enter a number to watch the Collatz Conjecture in action.")
  23. number = int(input())
  24. collatz()
RAW Paste Data
Top