Alibaba Group Interview Question

Implement a function to calculate factorial of x.