Explore Library
Code QuizIntermediate

Gamma Value Range

Identify why this discount factor causes returns to diverge.

Codejavascript
function computeReturn(rewards) {
  const gamma = 1.2; // discount factor
  let G = 0;
  for (let t = 0; t < rewards.length; t++) {
    G += Math.pow(gamma, t) * rewards[t];
  }
  return G;
}

What is the bug in this return computation?