Virtusa interview question

A pattern was given and code was asked regarding it