Implement an effcient algorithm to computer the factorial of a given number.
How do you handle overflow errors?