I am trying to replicate this Excel formula or for loop that calculates the current row value based on the previous row value of the same column. When value = 1, Result =