# How to find out the average salary?

I heard that this one was given problem in some job interview. Is this possible to do?

Three people wants to know what is their average salary but they don't want to tell their salary to others. How can they find out the average?

I couldn't think how to solve the problem.

First person passes the total of $S_1+R_1$ to person two where $S_1$ is her salary and $R_1$ is a random number known only to her. Person two then adds $S_2+R_2$ and passes $S_1+S_2+R_1+R_2$ to person three and person three adds $S_3+R_3$ and passes the total $S_1+S_2+S_3+R_1+R_2+R_3$ back to person one Now, person one subtracts $R_1$ and passes the result to person two who subtracts $R_2$ and passes the result to person three who subtracts $R_3$. What's left is $S_1+S_2+S_3$.
Call the salaries $X_1,X_2,X_3$. The first person generates a random number $R_1$ and tells the number $X_1+R_1$ to person two. Now, person two then does the same thing. Therefore, person three recieves the number $(X_1+R_1)+(X_2+R_2)$ Person three does the same thing and passes the result back to person one. Then they subtract out the random numbers that only they knew and divide by 3.