code for calculating factorial added