EPAM Systems interview question

A simple algorithm and some questions about Design Patterns