Advertisement
makispaiktis

AllNumbersGoTo1

Apr 10th, 2019 (edited)
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. # Main
  2. n = int(input("Enter n: "))
  3. print(n)
  4. try:
  5.     while n != 1:
  6.         if n%2 == 0:
  7.             n = n/2
  8.             print(n)
  9.         else:
  10.             n = 3*n + 1
  11.             print(n)
  12. except ValueError:
  13.     print("Value Error! You should have entered an unsigned integer number!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement