I want t calculation of arithmetical mean of four propeller and setting another additional propeller on that number

I want to create my copter code through Ardupilot (APM 2.6 version), where main principle is calculation of arithmetical mean of four propeller and setting another additional propeller on that number. In other words, I want t calculate arithmetical mean from out “pin 1” to “pin 4” and use it on “pin 8”. Can anyone help or/and give an advice to write this additional function and put it in the "“source code”?

I am sure if you put some more effort, any maybe lay out the way the code will work someone will be able to help you. Otherwise a cood place to get started working with arducopter code is the develpment site