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.
The usual trick is to pass a running total around:
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$.