Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print('Enter value please:')
- value=input()
- value=int(value)
- spam=0
- while value != 1:
- if value%2 == 0:
- print (value/2)
- value=int(value/2)
- spam=spam+1
- elif value%2 != 0:
- print(3*value+1)
- value=int(3*value+1)
- spam=spam+1
- #end the sequence if 1 is achieved and report results
- if value == 1:
- spam=str(spam)
- print ('Reduction complete.')
- print ('This value required '+spam+' steps.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement