Improving fact function
Making Problem 24 solution faster and nicer to read
Moving Problem 24