Update collatz.py

Made the algorithm a function instead of a program.