Added some code to num_factors.py