myprosperity interview question

Formulate an algorithm for primacy