Amazon interview question

Write a program for pattern generator