IBM Interview Question

Write code for a pattern