solved factorial problem