added lots to factor.py, solved problem 23