IBM interview question

Write code for a pattern