STM32 ADC and timer(s): Measuring moving average peak voltage of PWM signal with varying amplitude
If it were only a small number of averages then I would create a shift register.

Pseudo code for a small number of averages.

function movingAverage(pulseAverage) {
  static register[2];          // 3 registers
  register[2] = register[1];   // data shift
  register[1] = register[0];   // data shift
  register[0] = pulseAverage;  // move the input into the array
  return (register[2] + register[1] + register[0]) / 3;
}


For a larger number such as the 100 in your question this may use up too much precious RAM in a microprocessor. Instead, I would consider running an "eternal average", averaging all the values since the unit powered up.
For example, in your 100 cycle average you would calculate the new average as $$ avg = \frac {avg \times 99 + newRead}{100} $$.

This is very simple and requires only one variable. The downside is that it is a little more sluggish in its response. A quick spreadsheet simulation shows the following with averages of the last three cycles and "eternal average" with a weight of 1/3 for the new reading.



Figure 1. Simulation results.

You can try this out quite quickly in a spreadsheet.