Closed-form solutions to discrete-time portfolio optimization problems