HARMAN Interview Question

I was asked to write a program to generate some patterns