To calculate factorial of a number