add method to calculate factorial of a number.