Pregunta de entrevista de Reserve Bank of Australia

Convert this pseudo code to C#