Faster algorithm for factorial