On a Factorization Formula for the Partition Function of Directed Polymers