Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Hello! Today I will show you what a collatz is. Please insert a number!")
- integer=int(input())
- def collatz(number):
- while number != 1:
- if number % 2 == 0:
- big = number//2
- print ("Since " + str(number) +" is even, we divide it by 2 and get " + str(big))
- return int(big)
- elif number%2 ==1:
- small = number * 3 +1
- print ("Since" + str(number) +"is odd, we multiply by 3, add 1, and get" + str(small))
- return int(small)
- collatz(integer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement