Three coworkers would like to know their average salary. However, they are self-conscious and don't want to tell each other their own salaries, for fear of either being ridiculed or getting their houses robbed. How can they find their average salary, without disclosing their own salaries?
The first worker writes S =his salary +N (his secret number ),
passes it to the second worker.
The second worker adds his salary to S and passes this new sum to the third.
The third worker adds his salary and passes this new S to the first.
The first worker subtracts his secet number N.
He divides the result by 3 and gets the av. salary