collatz.py

xiaoxiao2021-02-28  8

# -*- coding: utf-8 -*- """ Created on Sat Feb  3 12:59:09 2018 @author: He Yuanwei """ def collatz(number):     try:         if number%2 == 0:             return number//2         elif number%2 == 1:             return 3*number + 1     except:         print('Please input an integer!') number = int(input('Enter number:\n')) while number!=1 :     print (collatz(number))     number = collatz(number)
转载请注明原文地址: https://www.6miu.com/read-2150096.html

最新回复(0)