Pregunta de entrevista de BlackBerry

Simple live coding question done in any language you want