Python编程快速上手 – 让繁琐工作自动化第2版 第三章 3.12.1 项目实践 Collatz序列 def collatz(num): while num != 1: if num % 2 == 1: num = 3 * num +