Write a formular on aprogram to generate the following patterns