Advertisement
Guest User

Untitled

a guest
May 16th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. ## objective of this program is to ask for a number. do operations on number based on its property. stop operation when it is at 1
  2.  
  3. def collatz(number):
  4. global result
  5. if number % 2 == 0:
  6. result = number // 2
  7. print(result)
  8. else:
  9. result = (number * 3) + 1
  10. print(result)
  11. return result
  12.  
  13.  
  14. while True:
  15. number = int(input("Please Enput a number"))
  16. collatz(number)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement