Tech Mahindra interview question

Was asked to write Program of Pattern and do its dry run