Printing sum in loop

To remember the value of a variable between loops, you need to declare it as static. Note that the declaration can put an initial value in the variable but that assignment is only done once, before the program starts.

void loop() {
  static float gainFin = 1.0;

  ...
}