Advertisement
Guest User

Untitled

a guest
Mar 18th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. print("Hello! Today I will show you what a collatz is. Please insert a number!")
  2. integer=int(input())
  3. def collatz(number):
  4. while number != 1:
  5. if number % 2 == 0:
  6. big = number//2
  7. print ("Since " + str(number) +" is even, we divide it by 2 and get " + str(big))
  8. return int(big)
  9. elif number%2 ==1:
  10. small = number * 3 +1
  11. print ("Since" + str(number) +"is odd, we multiply by 3, add 1, and get" + str(small))
  12. return int(small)
  13. collatz(integer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement