HARMAN interview question

I was asked to write a program to generate some patterns