daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest May 16th, 2018 114 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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)
RAW Paste Data
Top